sort

Function sort 

Source
pub fn sort(args: &[Value]) -> Result<Value, RuntimeError>
Expand description

对数字数组进行排序

§功能

对数字数组进行升序排序,返回新的已排序数组。原数组不会被修改。

§参数

  • array: Array - 要排序的数字数组

§返回值

Array - 升序排列的新数组

§错误

  • 数组包含非数字元素时抛出类型错误

§示例

Set nums [3, 1, 4, 1, 5, 9, 2, 6]
Set sorted Sort(nums)        # [1, 1, 2, 3, 4, 5, 6, 9]
Println(nums)                # [3, 1, 4, 1, 5, 9, 2, 6] (原数组不变)