Sort alphabetically a list of names
Hello everyone,
I don't want to believe that Intersystems didn't add a method/process/rule to sort alphabetically a list of names (in array, $ LB or whatever)
I haven't found any documentation about this. I've even tried comparing two strings but have not found a solution.
My cry for help is...
Does exists any command to compare two strings and check if one of them is lower or upper according to aphabet?
Please, give me a light in this dark
Best regards.
Kurro Lopez
Product version: HealthShare 2017.2
$ZV: Cache for Windows (x86-64) 2017.2.1 (Build 801_3U) Thu Apr 12 2018 10:02:23 EDT
Hi @Kurro Lopez
.png)
! The Follows operator is ]
while ] stands for Binary Follows
stands ]] for Binary Sorts After the difference is described there though it may sound esoteric at first sight.
In this case I think "sorts after" (]]) is better. So that locale is taken into the account.
just set it to the local array or global, will sort it
Thanks mate for your answer.
My goal was create an string with all codes of activity from a list, and it should be in order alphabetical because the list could be in other order and this key should be the same
Thanks for all your time and all explications about this.
Best regards,
Kurro
I like to use local multidimensional arrays as Dmitriy suggested.
Also, array objects are key/value based -- iterating through the keys always occurs in sorted order.
The reason that there is no sort "function", is that sorting is part of the basic storage structure that the whole system is built on. Arrays, both global and local, are automatically sorted as you set them up (effectively by an insertion sort). No need for a separate program or request. Just set up the data in an array as you go along and it will be sorted when you need it. This has always been a basic idea in the language, right from the original MUMPS, so the documentation may well skip over it a bit. However, when you get used to it, it works well.
For me, this was a fundamental revelation when I started working with Caché/ObjectScript. Where the $#&! is the sort function/method? I had naively assumed that arrays were simply associative with no intrinsic ordering, like Perl hashes.
When the light dawned ... 🤦♀️