后缀排序后,前缀需不需要排序?
比如将:
4554452@15.com
df4@15.com
shu54eijinat@15.com
445555@15.com
31jk21@15.com
排序成:
31jk21@15.com
445555@15.com
4554452@15.com
df4@15.com
shu54eijinat@15.com
楼上各位的想法很值得学习,2楼的502762378兄思路让人大开眼界,非常有创意.
如果前缀需要排序的话试试下面这个:
#include <array.au3>
Dim $str="4554452@15.com"&@CRLF& _
"ting455hai11985@1543.com"&@CRLF& _
"kel122ejiabing2002@163.com"&@CRLF& _
"shu54eijinat@15.com"&@CRLF& _
"445555@15.com"&@CRLF& _
"xahjhj1818@163.com"&@CRLF& _
"31jk21@15.com"&@CRLF& _
"ba24bymes@163.com"&@CRLF& _
"df4@15.com"&@CRLF& _
"we45nyibaoshe@123.com"&@CRLF& _
"hzc45546jf@1543.com"&@CRLF& _
"1112hgh233@163.com"&@CRLF& _
"sun545mingjie88@163.com"
$arr=StringRegExp($str,'[^\r\n]+',3)
Dim $arr2[UBound($arr)][3]
For $i=0 to UBound($arr)-1
$arr2[$i][0]=$arr[$i]
$arr2[$i][1]=StringFormat('%10s',StringRegExpReplace($arr[$i],'.+@',''))
Next
_ArraySort($arr2,0,0,0,1)
Local $k=1
For $i=0 to UBound($arr2)-2
If $arr2[$i][1]==$arr2[$i+1][1] Then
$arr2[$i][2]=$k
$arr2[$i+1][2]=$k
Else
$arr2[$i][2]=$k
$k+=1
EndIf
Next
For $k=1 to $arr2[UBound($arr2)-1][2]
$kk=_ArrayFindAll($arr2,$k,0,0,0,0,2)
_ArraySort($arr2,0,$kk[0],$kk[UBound($kk)-1],0)
Next
For $i=0 to UBound($arr)-1
$arr[$i]=$arr2[$i][0]
Next
_ArrayDisplay($arr)
$str=_ArrayToString($arr,@CRLF)
FileWrite("output.txt",$str)
|