您的位置:首页 > 运维架构 > Shell

字符串按照长度排序

2013-01-28 00:00 429 查看
VBA:

好像不能识别一些在excel里有特殊意义的字符。

Sub Button1_Click()

Dim max As Integer
max = 1
Dim lengths(200) As Integer
Dim tmp As String

For i = 1 To 200
max = i
tmp = Cells(i, 1)
If tmp = "" Then
Exit For
End If
For j = i + 1 To 200
If Cells(j, 1) = "" Then
Exit For
End If
If Len(Cells(max, 1)) < Len(Cells(j, 1)) Then
max = j
End If
Next
If i <> max Then
Cells(i, 1) = Cells(max, 1)

Cells(max, 1) = tmp
End If
Cells(i, 2) = Len(Cells(max, 1))
Next
End Sub

//最简单的是通过shell

awk '{ print length(), $0 | "sort -n" }' fileName

//通过sql, 将数据倒入Tmp表格

select len(fileName), fileName
from Test1
order by len(fileName)


[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息