|
Complex ascending and complex descending sorting |
Scroll |
Composite sorting rules combine sorting rules for graphs with different types of values. In this case, the lines are broken down into characters and digits, made up of adjacent characters. Then sequential comparison of characters and numbers is performed. The main difference between complex sorting and sorting in descending or ascending order is that numericals in any place of the string are taken into account. While normal sorting compares digits to digits and digits to characters, complex sorting compares numbers to numbers.
Strings from the previous examples after complex ascending sorting will be arranged as follows:
A25MP
A125GP
D25GP
D250MP
First, the first symbols were compared, and as a result, the strings starting with the character "A" came first in the list. During the further sorting of the strings "A25MP" and "A125GP", the comparison was made not between the digits "2" and "1", but between the numbers "25" and "125" As a result, the line containing the smaller number 25 turned out to be the first. In strings D25GP and D250MP it’s not the symbols 2 and 2, 5 and 5, G and 0 that were compared, but the numbers 25 and 250. As a result, the line containing the larger number 250 turned out to be the last.
This same list after the compound sorting in descending order (the rules of which are opposite to the rules of compound sorting in ascending order) will look like this:
D250MP
D25GP
A125GP
A25MP