I've got a dictionary of type [String : Int] that I need to create a sorted list from. The String is the name of the object, and the Int is the ID. I need to be able to sort the objects by their name alphbetically, but I can only reference them by their ID because two objects can be named the same thing, but the IDs will never be the same. Is there a way to turn that dictionary into an [Int] array of IDs so that if I were to pull the objects from these IDs they would be in alphabetical order? I also need it to be able to work with objects with the same name, which is really tripping me up at the moment. How can I do this?
Sorting [String : Int] pair alphabetically, even if there are duplicates
Add a Comment