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);

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now