例子 1
In this example we will create an array and sort it alphabetically:
输出:
Jani,Hege,Stale,Kai Jim,Borge,Tove
Borge,Hege,Jani,Kai Jim,Stale,Tove例子 2
In this example we will create an array and sort it alphabetically:
输出:
10,5,40,25,1000,1
1,10,1000,25,40,5请注意,上面的代码没有按照数值的大小对数字进行排序,要实现这一点,就必须使用一个排序函数:
输出:
10,5,40,25,1000,1
1,5,10,25,40,1000