字符串按照长度排序

VBA: sql

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

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)