CP-1.010 Java Tutorial - Sorting an ArrayList

preview_player
Показать описание


Regarding the compareTo function, I forgot to mention that, given two objects o1 and o2, if o1 is smaller than o2, then you should return -1, and if o1 is bigger than o2, you should return 1 (you return 0 if they are equal, as I mentioned in the video).

Video Sections:
0:00 - ArrayList
2:31 - Sorting an ArrayList
6:49 - Problem description
8:20 - Solution
10:34 - Custom Sorting using comparator
14:50 - Custom sorting using lambda operator

Please note that all views and opinions expressed in this video are my own and does not reflect that of Kattis or any other person/organisation mentioned in the video.
Рекомендации по теме