LlListSort
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| Function: list llListSort( list src, integer stride, integer ascending ); |
| 参数:
list src – List to be sorted. integer stride – number of entries per stride, if less than 1 it is assumed to be 1 integer ascending – if TRUE then the sort order is ascending, otherwise the order is descending. |
| 返回值:
返回一个按 stride 排序的 src 列表。 |
| 注意事项 |
|---|
*它使用了一个未优化的选择排序算法,这是一个大 o 为 n2的算法。Jira 的问题是为了改善这个功能 svc-2988。
llListSort([2, "B", "C", 3, 1, "A"], 1, FALSE) // returns ["A", 3, 1, "C", "B", 2] 但是,如果没有混合类型,那么下降类型就可以正常工作。
llListSort(["127", "3", "25"], 1, TRUE) // returns ["127", "25", "3"] because the 1 in 127 is before the 2 in 25 which is before the 3 To sort them in numeric order, numbers in strings can be padded with zeros: llListSort(["127", "003", "025"], 1, TRUE) // returns ["003", "025", "127"]
|
| 示例 |
|---|
示例一
list numbers = [3, "three", 2, "two", 1, "one"];
default
{
state_entry()
{
llOwnerSay(llDumpList2String(numbers, ","));
// Object: 3,three,2,two,1,one
numbers = llListSort(numbers, 2, TRUE);
llOwnerSay(llDumpList2String(numbers, ","));
// Object: 1,one,2,two,3,three
}
}
|
| 相关函数 |
|---|
| llListRandomize--重新整理列表的元素。 |
| 相关事件 |
|---|