Created
October 16, 2022 13:52
-
-
Save rmg007/fbac9e2ce7ae1fd3b785043ae1967fc9 to your computer and use it in GitHub Desktop.
Sort Lis tUsing Comparato rReverse Order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.Comparator; | |
| import java.util.List; | |
| public class SortListUsingComparatorReverseOrder { | |
| public static void main(String[] args) { | |
| List<Integer> list = new ArrayList<>(List.of(3, 6, 8, 2)); | |
| list.sort(Comparator.reverseOrder()); | |
| System.out.println(list);//output [8, 6, 3, 2] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment