[已解决] 数字字符串以降序排序
本帖最后由 chishingchan 于 2018-5-4 16:22 编辑之前的问题“[求助] 关于时间长度的数据排序”没有人帮上忙,
http://www.autoit3.cn/thread-56755-1-1.html
经搜索,觉得可用,略加修改,发现总是出错。
http://www.autoit3.cn/forum.php?mod=viewthread&tid=22896
请高手帮个忙,数字字符串以降序排序,谢谢!
修改后出错的源码:#include <array.au3>
local $array=["1|3","2|8","3|7","4|1","5|2","6|5","7|6","8|4","9|44","10|2","11|11","12|35","13|93","14|22","15|12"]
$timer=TimerInit()
quicksort($array,0,15)
_arraydisplay($array,TimerDiff($timer))
func quicksort(ByRef $arr,$beg=0,$end=0)
If $End <= $beg Then Return
If $End < 1 Or $End > UBound($arr)-1 Then $End = UBound($arr)-1
If $beg < 0 Then $beg = 0
If $beg > $End Then Return SetError(2, 0, 0)
local $key=StringSplit($arr[$beg],"|")
local $l=$beg
local $h=$end
While $l<$h
while Number($key) <= Number(StringSplit($arr[$h],"|")) and $l<$h
$h-=1
WEnd
$arr[$l]=$arr[$h]
while Number(StringSplit($arr[$l],"|")) <= Number($key) and $l<$h
$l+=1
WEnd
$arr[$h]=$arr[$l]
WEnd
$arr[$l] = StringSplit($arr[$l],"|") & Number($key)
$l+=1
quicksort($Arr, $beg, $h)
quicksort($Arr, $l, $end)
EndFunc #include <Array.au3>
Local $aArray = [, , , , , , , , , , , , , , ]
_ArraySort($aArray, 1, 0, 0, 1)
_ArrayDisplay($aArray) 回复 2# afan
短小精悍!膜拜!谢谢!
页:
[1]