Suggestions for improving sorting, especially of personal names

Suggestions for improving sorting, especially of personal names

ma_robergema_roberge Posts: 29Questions: 9Answers: 0

The examples used on the DataTables website have names in the first column, always in the format "First name Family name". Unfortunately, names so ordered cannot be sorted correctly. Wouldn't it be great to tell DataTables to use the second word? Obviously, one might have to insert   (unbreakable spaces) between the parts of the string to be treated as first name, e.g., "Johann Sebastian Bach".

For users who have to deal with languages (or names) that contain diacriticals (e.g., acute, grave, and circumflex accents), it would be very helpful if accented letters were sorted like their unaccented counterparts instead of begin sent at the end of the list, which is sorting as it was done in the early days of computing.

Likewise, it would be helpful to be able to disregard an initial article (a, an, the, le, la, les, der, das, die, etc.), such as is found constantly in book and article titles. Another nice touch would be the possibility of disregarding an opening quotation mark, often found in book titles.

I have also observed that, when searching text using "Individual column searching (text inputs)", a string containing a curly apostrophe (coded with ’) will not be found, since one types an ASCII apostrophe (') in the search box. If quotation marks and apostrophes were treated by DataTables like their plain ASCII versions, things would be easier. I am ready to admit that this last point may not be a priority since this would apply only if one copied and pasted into a search box a string found elsewhere.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    Wouldn't it be great to tell DataTables to use the second word?

    Sure - feel free to do so :-). You can use orthogonal data to do so, or a custom ordering plug-in.

    Likewise, it would be helpful to be able to disregard an initial article (a, an, the, le, la, les, der, das, die, etc.), such as is found constantly in book and article titles

    Again a plug-in would be used for this - this one strips the, but could readily be expanded. If you do so, please do send a pull request so others can also use it.

    If quotation marks and apostrophes were treated by DataTables like their plain ASCII versions, things would be easier.

    This can also be done with a filtering plug-in, or better yet, orthogonal data with the value to want to search.

    Thanks for the suggestions - all good! DataTables is designed to be flexible and not do "magic" out of the box - it causing far too much hassle to undo it, and means deadweight code for those that don't want those features.

    Allan

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394
    Answer ✓

    If you use a database, the best way to handle names and titles is to store their component parts in separate fields. Those parts can then be combined quite easily for simple display purposes, with sorting and filtering achieved by using only the relevant part (e.g. last name).

  • ma_robergema_roberge Posts: 29Questions: 9Answers: 0

    I see the basic principle behind orthogonal data, which needs an additional column providing the data formatted in a way that makes correct sorting possible. Currently my website does not use a database. DataTables simply uses my static tables (and does a very nice job, I should add).

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin

    which needs an additional column providing the data formatted in a way that makes correct sorting possible

    not really - you could use columns.render and "transform" the data as needed.

    Allan

This discussion has been closed.