I have a list of strings which contains special characters in it, The list is below:
1.Kevin_richard
2.Dan_ronald
3.Daniel_white
4.David_jacob
5.eddie_bacon
To sort the list in ascending order I have used Sort List(The strings are sorted alphabetically and the numbers numerically) keyword from collections library.
*** Settings ***
*** Test Cases ***
TC Title
Sort the given list of usernames in ascending order
*** Keywords ***
Sort the given list of usernames in ascending order
${sorted_order_asc}= Copy List ${default_order_username} //default order represents list of five user names
Sort List ${sorted_order_asc}
On executing the above script, the list is sorted in the following order:
- Daniel_white
- Dan_ronald
- David_jacob
- eddie_bacon
- Kevin_richard
But this is not the expected sort order. In the above list, Dan_ronald has to be at the top of the list. Sort List ignores special characters hence underscore after Dan is skipped and checks for the next alphabet(r vs i). As a result of it, Daniel_white tops the list.
Any help to sort out this issue will be appreciated.