通过排序键遍历HashMap

时间:2017-10-10 10:02:03

标签: elasticsearch-painless

我试图弄清楚如何通过按升序排序的按键迭代无痛HashMap值,以下不起作用:

Sub CorrectIncorrectNumberFormat()
    With Application
        .UseSystemSeparators = False
        .DecimalSeparator = ","
        .ThousandsSeparator = "."
    End With

    'Update to your applicable range I've set it to sheet1 Column A
    With Sheet1
        With Range(.Cells(1, 1), .Cells(.Cells(.Rows.Count, 1).End(xlUp).Row, 1))
            .TextToColumns Destination:=.Cells(1), DataType:=xlDelimited, _
                TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
                Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
                :=Array(1, 1), TrailingMinusNumbers:=True
        End With
    End With

    With Application
        .DecimalSeparator = "."
        .ThousandsSeparator = ","
        .UseSystemSeparators = True
    End With
End Sub

1 个答案:

答案 0 :(得分:2)

最后通过使用ArrayList找到了一种方法,但绝对不确定它是否可行:

HashMap buckets;
ArrayList l = new ArrayList(buckets.keySet());
Collections.sort(l);
for(String bucketKey : l) {
    // actual code
}