7 Replies Latest reply on Jul 27, 2012 6:08 PM by DrClap

    Exact Match on the top of the List

      Hi All,

      I have a list as ArrayList<User> where User class contains some fields including firstname,lastname and userID.
      Given a search string say "searchString", I need to sort the list in a way that EXACT matches in the list ON the fields firstname,lastname or userID comes on the top and then the others. All the entries already satisfies the partial matching criteria. Just need to get the exact matches on the TOP of the List

      Example: if ArrayList<User> contains {{"hominder","kumar" ,"lpppp"},{"leethom","chuu" ,"lpppx"},{"thomas","dorothy" ,"lxoxp"},{"paul","meyer" ,"thomyg"},{"hom","jones" ,"lwppp"},{"susana","hom" ,"lpipp"}}
      where {"ajay","kumar" ,"lpppp"} denotes firstname,lastname and userID of User respectively.

      In this case if searchString = "hom", the I should get {"hom","jones" ,"lwppp"} and {"susana","hom" ,"lpipp"}} on the top of the list as they are exact matches. Kindly let me know a TIME Efficient way to do this because traffic of my site is much and most of them are managers. Any help is much appreciated.