1

What i would like to do is have a method that takes in a string which will be the column name and return a sorted list by that column

@Command(description="Get all Activities")
  public void getActivities (String sortedBy)
  {
    List<Activity> activityList = new ArrayList<Activity> (paceApi.getActivities());
    // Sort by Parameter
    IASCIITableAware asciiTableAware = new CollectionASCIITableAware<Activity>(activityList, "firstname", "lastname", "email"); 
    ASCIITable.getInstance().printTable(asciiTableAware);
  }

Is there a Collections method that can do this or is there another way?

Thanks

user237462
  • 387
  • 1
  • 5
  • 24
  • I might be reading it wrong but it doesn't seem to account for the multiple fields. It assumes that you are always sorting by the same field. – user237462 Oct 24 '17 at 11:20
  • 1
    @user237468: Same principle, if you understand how comparator works then all you need is a switch on the sortedBy parameter and change the comparator logic accordingly – OH GOD SPIDERS Oct 24 '17 at 11:23

0 Answers0