How to sort alphanumeric values using groovy ?For example : I have list of values [ADF1SD23GF12,UTRR453FGT3,NKUY43ERT5,56GHY123,MU157FGR234,...] I want to get result as in Excel sorting for this values. Could someone help?
List1.sort{ a,b -> a <=> b }
There are probably some differences between what you're after and what the close to the default sorting does, but you can modify this example to get there:
Prints:
Of course you can simply the first one to simply:
But I left it with the closure to illustrate how to sort ascending vs descending.