Skip to content

Sorting

Will Davies edited this page Feb 17, 2019 · 1 revision

With version 1.0.6, certain models can be sorted based off different settings.

The following sort options available are:

    DEFAULT
    NAME
    NUMBER
    DATE
    RANK
    TEAM

To sort an array, use the TBA.sort() function:

Event[] events = new TBA().getEvents(2019);
TBA.sort(events); // leaving off a type will sort by a preset default
TBA.sort(events, SortingType.NAME); // events is now sorted alphabetically
TBA.sort(events, SortingType.DATE); // events is now sorted by date
TBA.sort(events, SortingType.NAME, false); // you can also set ascending to false, now events are sorted in reverse alphabetically

Only arrays may be sorted. The following describes the available arrays that may be sorted and the allowed sorting types:

Event[] events; // DATE, NAME
SEvent[] sevents; // DATE, NAME
Team[] teams; // NUMBER
STeam[] steams; // NUMBER
Robot[] robots; // DATE
Alliance[] alliances; // NAME
Match[] matches; // NUMBER, DATE
SMatch[] smatches; // NUMBER, DATE
EventRanking[] rankings; // RANK, TEAM
EventOPR[] oprs; // RANK, TEAM
Clone this wiki locally