Is it possible to sort a HashTable?

前端 未结 11 734
不知归路
不知归路 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:52

    Of course hash tables can be sorted, but you need to first define what it means to sort a hash table. (Therein lies the issue)

    Once you have done that, however, you've invariably removed all the advantages that a hashtable can give you, and you might as well use a sorted array (with binary searching), or use a red-black tree instead.

提交回复
热议问题