Dialog List values to sort in ascending order

71 views Asked by At

I am in need of your help. I have a dialog list return where elements in selectionList are the following:

Grade 10A Grade 10B Grade 11A Grade 8 Grade 9H

@Return(@Trim(@Sort(@Unique(selectionList);[Ascending] )))); "")

I want them to show them in the following manner: Grade 8 Grade 9H Grade 10A Grade 10B Grade 11A

Any suggestions what formula in the @Return to be used?

Thank you!

1

There are 1 answers

0
Knut Herrmann On

Sort by number (max. two digits):

_list := @Unique(selectionList);
_numberList := @Right("00" + @Text(@ToNumber(@Right(_list; "Grade "))); 2);
@Return(@Right(@Sort(_numberList  + "#" + _list); "#"))

Keep in mind that functions like @Prompt([OkCancelList]; ...) sort the list on their own and will resort (=ruin) your sorted list.

Example:

if _list is
Grade 10B
Grade 11A
Grade 10A
Grade 8
Grade 9H

then _numberList will be
10
11
10
08
09

@Sort() will get as parameter
10#Grade 10B
11#Grade 11A
10#Grade 10A
08#Grade 8
09#Grade 9H

@Right() will get as parameter
08#Grade 8
09#Grade 9H
10#Grade 10A
10#Grade 10B
11#Grade 11A

and @Return() will return
Grade 8
Grade 9H
Grade 10A
Grade 10B
Grade 11A