-
Notifications
You must be signed in to change notification settings - Fork 460
ListSortingRecipes
Demonstrates how to sort lists using the Comparator Interface
Group Collection Recipes
See AccountShippingCountryComparator
See AccountNumberOfEmployeesComparator
Demonstrates how to sort a list of Account using Comparator Interface
In this example we pass in the implementation class AccountShippingCountryComparator
as a parameter to the sort method of a list. This method sorts Accounts
by shipping address in ascending alphabetical order
public static void sortAccountsByShippingCountry(List<Account> accounts)
Name | Type | Description |
---|---|---|
accounts | List<Account> | a list of accounts that will be sorted in place |
void
Demonstrates how to sort a list of Account using Comparator Interface
In this example we pass in the implementation class AccountShippingCountryComparator
as a parameter to the sort method of a list. This method sorts Accounts
by shipping address in descending alphabetical order
public static void sortAccountsByShippingCountryInDescending(List<Account> accounts)
Name | Type | Description |
---|---|---|
accounts | List<Account> | a list of accounts that will be sorted in place |
void
Demonstrates how to sort a list of Account using Comparator Interface
In this example we pass in the implementation class AccountNumberOfEmployeesComparator
as a parameter to the sort method of a list.This method sorts Accounts
by employee number in the ascending order
public static void sortAccountsByNumberOfEmployees(List<Account> accounts)
Name | Type | Description |
---|---|---|
accounts | List<Account> | a list of accounts that will be sorted in place |
void