Skip to content

格式

typescript
List.Sort(sort_function)

所属类: List

描述

对列表中的元素进行排序。

参数

参数名类型描述
sort_functionFunction排序方式

返回值

类型描述
void

代码示例

typescript
let list = new List<Number>(Number);
list.AddRange([100, 200 , 300]);
//将列表中的元素按从大到小排序        
const customSort = (a: number, b: number): number => b - a;
list.Sort(customSort);