Replace hash table with sorted array