How can i sort alphanumeric strings in ascending order?
For eg: I have an array of strings like {34fghj4,asdg456,bhfg23s,bhfg12b,tyui123}
I want to sort it in ascending order like – {34fghj4,tyui123,bhfg12b,bhfg23s,asdg456}
where the string containing the numerical in the first place is considered the smallest)
Numerical always gets the first priority, we need to select the string based on the postion of numberical. in tyui123 and bhfg12b – in the last position tyu i123 has 3 which is a numerical
.hence it gets priority
in your example, the order has to be 35abc,ty123,abc23s…because ty123 has 1 in the 3rd position and abc23s has c in the third position. hence, ty123 gets priority
Sorry but I couldn’t get your logic. Can you share step by step logic for your sorting?
First, evaluate numeric character position which appears first. So 34fghj4 is first position, is this right so far?
The first numeric character of all remaining is 5th. We need next evaluation for them.
Next, how do we evaluate these string?
so, the logic is numerical takes priority. And the place at which numerical is placed takes priority and the lesser numerical value takes priority(ascending)