Groovy list.sort by first, second then third elements

前端 未结 7 1156
旧时难觅i
旧时难觅i 2021-02-02 09:42

I have a groovy list of lists i.e.

list = [[2, 0, 1], [1, 5, 2], [1, 0, 3]]

I would like sort it by order of the first element, then second, th

相关标签:
7条回答
  • 2021-02-02 10:15

    You can do it in one line:

    list.sort { String.format('%010d%010d%010d', it[0], it[1], it[2]) }
    
    0 讨论(0)
提交回复
热议问题