Name |
sort()排序 |
||||
Examples |
float[] a = { 3.4, 3.6, 2, 0, 7.1 }; a = sort(a); println(a); // Prints the contents of the sorted array: // [0] 0.0 // [1] 2.0 // [2] 3.4 // [3] 3.6 // [4] 7.1
String[] s = { “deer”, “elephant”, “bear”, “aardvark”, “cat” }; s = sort(s); println(s); // Prints the contents of the sorted array: // [0] “aardvark” // [1] “bear” // [2] “cat” // [3] “deer” // [4] “elephant”
String[] s = { “deer”, “elephant”, “bear”, “aardvark”, “cat” }; s = sort(s, 3); println(s); // Prints the contents of the array, with the first 3 elements sorted: // [0] “bear” // [1] “deer” // [2] “elephant” // [3] “aardvark” // [4] “cat” |
||||
Description |
Sorts an array of numbers from smallest to largest, or puts an array of words in alphabetical order. The original array is not modified; a re-ordered array is returned. The count parameter states the number of elements to sort. For example, if there are 12 elements in an array and count is set to 5, only the first 5 elements in the array will be sorted. 将数字数组从最小到最大排序, 或按字母顺序排列单词数组。原始阵列未修改;返回一个重新数组。count 参数表示要排序的元素数。例如, 如果数组中有12元素, 并且 count 设置为 5, 则只对数组中的前5元素进行排序。 |
||||
Syntax |
sort(list) sort(list, count) |
||||
Parameters |
|
||||
Returns |
byte[], char[], int[], float[], or String[] |
||||
Related |
- 本文固定链接: http://iprocessing.cn/2017/07/21/sort排序/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表