Sort a list of sObject records based on a field value | Salesforce Apex Tutorial Series by SFDC Stop

Опубликовано: 16 Июль 2026
на канале: SFDC Stop
4,830
61

Hello Trailblazers, In this video we're going to learn how we can sort a list of sObject records based on a field value. In the previous two tutorials, we learned about enums and custom comparator. In this tutorial we're going to put those two concepts in action and solve a real world problem.

Custom Comparator Tutorial:    • Apex List Comparator | System.ListExceptio...  
Enum Tutorial:    • Enums in Apex | What is Enum and where do ...  

Chapters:
0:00 Introduction
2:30 Code snippet explanation
3:16 SortUtil class - properties
4:02 Constructor of SortUtil class
4:19 sortRecords() method of SortUtil class
6:40 sort() method explanation - compareTo() method
9:20 compareStrings() method
11:08 sort() method wrap up
11:57 Verifying results
13:16 Wrapping up

Code Snippet: https://gist.github.com/rahulmalhotra...

Code of SortUtil Class: https://github.com/rahulmalhotra/apex...

Subscribe to SFDC Stop:- https://www.youtube.com/c/sfdcstop?su...

LWC Todo App Project Tutorial Series -    • Simplifying the Callouts in Salesforce | H...  

Interested in learning about Scratch Orgs and SFDX ? Have a look at the playlist:-    • Getting started with Scratch Orgs and CI/C...  

Interested in learning about Integration ? Have a look at this playlist:-    • Salesforce Integration Tutorial Series