Is it possible to sort a HashTable?

前端 未结 11 715
不知归路
不知归路 2021-01-17 10:13

I have a property that returns a HashTable. I would like to sort it without refactoring my property. Please note: I do not want to return another type.

11条回答
  •  醉梦人生
    2021-01-17 10:46

    Another option is to construct the hash table as you're already doing, and then simply construct a sorted set from the keys. You can iterate through that sorted key set, fetching the corresponding value from the hash table as needed.

提交回复
热议问题