@@ -5076,18 +5076,19 @@ protected PostResult computePost(List<Candidate> possible, Candidate selection,
50765076
50775077 protected PostResult computePost (List <Candidate > possible , Candidate selection , List <Candidate > ordered , String completed , Function <String , Integer > wcwidth , int width , boolean autoGroup , boolean groupName , boolean rowsFirst ) {
50785078 List <Object > strings = new ArrayList <>();
5079+ boolean customOrder = possible .stream ().anyMatch (c -> c .sort () != 0 );
50795080 if (groupName ) {
50805081 Comparator <String > groupComparator = getGroupComparator ();
5081- Map <String , Map <String , Candidate >> sorted ;
5082+ Map <String , Map <Object , Candidate >> sorted ;
50825083 sorted = groupComparator != null
50835084 ? new TreeMap <>(groupComparator )
50845085 : new LinkedHashMap <>();
50855086 for (Candidate cand : possible ) {
50865087 String group = cand .group ();
50875088 sorted .computeIfAbsent (group != null ? group : "" , s -> new LinkedHashMap <>())
5088- .put (cand .value (), cand );
5089+ .put (( customOrder ? cand .sort () : cand . value () ), cand );
50895090 }
5090- for (Map .Entry <String , Map <String , Candidate >> entry : sorted .entrySet ()) {
5091+ for (Map .Entry <String , Map <Object , Candidate >> entry : sorted .entrySet ()) {
50915092 String group = entry .getKey ();
50925093 if (group .isEmpty () && sorted .size () > 1 ) {
50935094 group = getOthersGroupName ();
@@ -5102,13 +5103,13 @@ protected PostResult computePost(List<Candidate> possible, Candidate selection,
51025103 }
51035104 } else {
51045105 Set <String > groups = new LinkedHashSet <>();
5105- TreeMap <String , Candidate > sorted = new TreeMap <>();
5106+ TreeMap <Object , Candidate > sorted = new TreeMap <>();
51065107 for (Candidate cand : possible ) {
51075108 String group = cand .group ();
51085109 if (group != null ) {
51095110 groups .add (group );
51105111 }
5111- sorted .put (cand .value (), cand );
5112+ sorted .put (( customOrder ? cand .sort () : cand . value () ), cand );
51125113 }
51135114 if (autoGroup ) {
51145115 strings .addAll (groups );
0 commit comments