Create a SortedMap in Java with a custom Comparator

后端 未结 2 1802
一生所求
一生所求 2020-12-03 16:58

I want to create a TreeMap in Java with a custom sort order. The sorted keys which are string need to be sorted according to the second character. The values ar

2条回答
  •  余生分开走
    2020-12-03 17:45

    Assuming you don't mean Hash as in hash function or the sort...

    You could easily accomplish this by creating a "wrapper" class for String and overriding the compareTo method

提交回复
热议问题