For example, if we have strings like ["welcome", "to", "pega", "systems", "community"], now this list of strings can be sorted either ASC|DSC order. But how can the list of these strings can be sorted based on some string?
Lets assume my string is "peg" then if you want to display the strings which starts with "peg" first then how you will define the order of the remaining strings?
I dont think this functionality can be achieved as the expected end result is not clear. If you are aware of the expected end result based on the given string could you let us know with a sample example.
Posted: 6 years ago
Posted: 11 Jan 2017 2:06 EST
Arun Kumar Regulapati (ArunKumarR6214)
For example, if we have people with Names having 'Ervin' as a substring, If we search for people with name Ervin, then the results should start with Ervin, and then next preference to the results having Ervin as substring.
Currently results coming in the below format.
-- ABC, Ervin
-- BCD, Ervin
-- CDE, Ervin
-- DEF, Ervin
-- Ervin, KLM
-- Ervin, LMN
-- Ervin, MNO
-- FGHI, ABCERVIN
Expected result should have results start with Ervin as starting string in the first preference,then the next preference to the Ervin as substring.
OOTB we can't acheive this requirement. You may have to write your own function.
As a workaround, I would suggest you to spli the list into 2 different lists, one having names starting with Ervin (for example) and another one which doesn't start with that name. Now, sort it in accending order. Once sorting is done, append the 2nd list to the 1st one.