Hi, I have implemented string natural comparison and sorting in the last Gambas 3 revision.
With that, you can, for example, sort a file name array returned by Dir() that way: Photo1.jpg Photo1a.jpg Photo1b.jpg Photo2.jpg ... Photo9.jpg Photo10.jpg Photo11.jpg Instead of: Photo1.jpg Photo10.jpg Photo 11.jpg Photo1a.jpg Photo1b.jpg Photo2.jpg ... Photo9.jpg For that, use the gb.Natural constant as sort flag. Moreover, if you have non-ASCII letters, you can add gb.Language to the flag, and non-ASCII characters will be correctly sorted too. You will get: Baba.jpg Bébé1.jpg Bébé8.jpg Bébé20.jpg Bibi.jpg Bobo.jpg instead of: Baba.jpg Bibi.jpg Bobo.jpg Bébé1.jpg Bébé20.jpg Bébé8.jpg How does it work? The string is splitted between parts having digits only (0-9), and parts having no digits. Parts having no digits are sorted as normal strings. Parts having digits are sorted according to their numerical values, unless it starts with a zero. Enjoy it! -- Benoît Minisini ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user