我有一个HashMap<String, Float>充满了几个条目.我想将HashMap的键保存到一个ArrayList<String>,但是根据HashMap的相应值对这个ArrayList进行排序.
有没有比排序HashMap更好的解决方案,然后使用
ArrayList<String> sortedKeys = new ArrayList<String>(myHashmap.keySet());
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我不必首先使用HashMap,但是值设置了顺序,我不想要交换键和值,因为float可能会改变几次.