[Gambas-user] Sorting the human way
Jorge Carrión
shordi at ...626...
Wed Oct 23 10:17:17 CEST 2013
Very interesting. Thanks a lot.
Regards
2013/10/23 Alain Baudrez <a.baudrez at ...626...>
> Hoi,
>
> I've never been happy with the standard sorting algorithm when dealing with
> lists of names. The human eye expects the names to be listed
> alphabetically, overlooking spaces, hyphens, accented characters, ...
>
> Assume the following names:
> - Benoizy
> - Benoît
> - Benï Lewis
> - Benoix
> - Ben Underwood
>
> Sorting them using the default sort method results in the following list:
> - Ben Underwood
> - Benoix
> - Benoizy
> - Benoît
> - Benï Lewis
>
> Ben Underwood comes first due to the space having an UTF-8 value of
>
> Benoît comes last in the Benoi series of names due to the UTF-8
> value of î which is ï
> Benï Lewis comes last of the list as ï has a UTF-8 value of î
>
> Using the function Alfabet to sort the list, the end result using the
> original strings appears in the form :
> - Benï Lewis
> - Benoît
> - Benoix
> - Benoizy
> - Ben Underwood
>
> which is the normal order a human expect to see when you ignore
> spaces, accents, umlauts, ...
>
> In annex I sent a function I have written that strips a string from all the
> non-letter characters and returns a simple pure ascii string with all
> characters in the range "a"-"z". Also included a small snapshot of an
> actual list sorted by alphabet in one of my programs. As you notice, the
> names are truly listed 'by Alphabet'
>
> Feel free to use the function or maybe the concept could be incorporated in
> a future build of Gambas
>
> Alain J. Baudrez
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
More information about the User
mailing list