package com.safemobile.lib.radio; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Zone { public int dbID; public int id; public String ZoneName=""; public ArrayList channelList = new ArrayList(); public Zone() { channelList = new ArrayList(); } public String toString() { return "zoneDbID: " + id +" |zoneID: " + dbID + " | ZoneName: " + ZoneName ; } /** * sort the list of channels based on their names */ public void sortChannelListByName() { //Sorting Collections.sort(channelList, new Comparator() { @Override public int compare(Channel channel1, Channel channel2) { return channel1.chName.compareTo(channel2.chName); } }); } /** * sort the list of channels based on their ids */ public void sortChannelListByChannelID() { //Sorting Collections.sort(channelList, new Comparator() { @Override public int compare(Channel channel1, Channel channel2) { return (channel1.id < channel2.id ? 1 : 0); } }); } }