Using sorting of received data

The data obtained from the API methods calls of the main interface of the library, in most cases, represent collection classes (Players, Events, Matches) which can be sorted by certain parameters for convenience of further use in client applications.

The types of possible sorts for specific collection classes are listed below.


Players - entity class which contains a selection of players on certain parameters.
This class provides two types of sorting:

1. Sorting players by name.

2. Sorting players by age, both in descending order and in ascending order.

Java code that shows all the above sorting methods is presented below:

Players players = Snooker.API().getPlayers(...);
...
players.sortByName();
...
players.sortByAge();
players.sortByAgeDesc();
...

Events - entity class which contains a selection of tournaments for certain parameters.

Java code that shows the sorting of tournaments by date is presented below:

Events events = Snooker.API().getSeasonEvents((...);
...
events.sortByDate();
...

Matches - entity class which contains a selection of matches for certain parameters.
This class provides two types of sorting:

1. Sorting matches by number.
This sorting type will be useful when the selection contains all the matches of a single tournament.

2. Sorting matches by tournament.
This sorting type will be useful when the selection contains all the matches of an individual player for the season in different tournaments.

Java code that shows all the above sorting methods is presented below:

Matches matches = Snooker.API().getEventMatches((...);
...
matches.sortByNumber();
...
matches.sortByEvent();
...