+ Reply to Thread
Results 1 to 2 of 2

Thread: Reverse Sorting order

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    16

    Reverse Sorting order

    I`d like to know how to implement ascending sort when the comparator sorts descending?
    Refering to that code :
    Code:
    public void sortBySubjectAscending()
    {
    Collections.sort(data, Collections.reverseOrder(new Data.SubjectDescendingComparator()));
    }

  2. #2
    Junior Member
    Join Date
    Feb 2012
    Posts
    19
    If you reverse a descending comparator, you get an ascending comparator.
    To break it down, this is what you are doing:
    Code:
    Comparator ascending = Collections.reverseOrder(new Email.SubjectDescendingComparator());
    Collections.sort(emails, ascending);

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts