5 Replies Latest reply: Sep 15, 2012 2:59 AM by EJP RSS

    Combining the sorted lists in a third list


      I have 6 records which I retrieved for a customer number entered, among which for the first 3 records I have Billing name populated.
      Hence i have sorted the first 3 records using billing name before displaying the search result. For the next 3 records billing name
      is not populated, hence i have sorted the next 3 records using customer Id before displaying the search result.
      Hence I have segregated the 6 records in to 2 lists each containg 3 records each.

      collections.sort(list1, new BillingNameComparator());
      collections.sort(list2, new CustomerIdComparator());

      Here as per the above list1 will be sorted using billing name and list2 will be sorted using the CustomerId. Now when I display
      final search result I need to make sure the list1 records(billing name sort) are displayed first followed by the list2 records(Customer Id sort).
      Hence i have created a t5hird list list3 in which i add list1 and list2.


      But i do this the records are displayed in a random order and not in the sorted order which is set in the list1 and list2.

      Please clarify where I am going wrong.