字符串按照長度排序

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)
相關文章
相關標籤/搜索