How To Sort List of Maps?

How To Sort List of Maps?

I have the following below; If I return Collection(keyList) at the bottom, keyList is sorted correctly (I've tried both true and false and it works). But when I add to my sortedList in the order of my keyList the sortedList is not sorting how I want - its just returning unsortedList as-is. I got this syntax/help from another website...any other ideas out there?
  1. unsortedList = invokeurl
  2. [
  3. url :"https://api.discogs.com/database/search?token=helloZoho"
  4. type :GET
  5. parameters:paramsMap
  6. ];
  7. sortKey = "id";
  8. keyList = List();
  9. for each  u in unsortedList.getJson("results")
  10. {
  11. keyList.add(u.getJson(sortKey));
  12. }
  13. keyList = keyList.distinct().sort(true);
  14. sortedList = List();
  15. for each  k in keyList
  16. {
  17. for each  u in unsortedList
  18. {
  19. if(u.getJson(sortKey) == k)
  20. {
  21. sortedList.add(u);
  22. }
  23. }
  24. }
  25. return Collection(sortedList);