Ancient Egyptian Sorting Order

Ancient Egyptian Sorting Order

egyptdbegyptdb Posts: 3Questions: 1Answers: 0

Hi everybody,

I'm very new to web development/javascript, and I'm having trouble developing a script to sort a column by the ancient Egyptian alphabet rather than English (even after using https://www.datatables.net/plug-ins/sorting/ as a reference).

My question is, in the examples where users are using an array/dictionary to specify a new alphabet, what is happening? The ordering of the Egpytian alphabet (as encoded by a certain standard) is AjtawbpmnrhHxXzsSKkgtTdD -- capitals matter because they are used to represent different characters (for example A represents ꜣ). I tried to specify this ordering by adjusting the existing Czech alphabet plugin-- but I'm too ignorant of what is actually happening here to understand why it isn't working. Can anybody provide a little advice? Even just in the form of where to look so I can begin to recognize what's happening here?
Included below is my adjustment of the Czech alphabet plugin.

/@egyptstring js/

$.extend( $.fn.dataTableExt.oSort, {
"egypt-pre": function ( a ) {
var special_letters = {
"A": "A", "j": "j", "y": "y", "a": "a",
"w": "w", "b": "b", "p": "p", "m": "m",
"n": "n", "r": "r", "h": "h", "H": "H",
"x": "x", "X": "X", "z": "z", "s": "s", "S": "S", "K": "K",
"k": "k", "g": "g", "t": "t", "T": "T",
"d": "d", "D": "D"
};
for (var val in special_letters)
a = a.split(val).join(special_letters[val]);
return a;
},

"egypt-asc": function ( a, b ) {
    return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},

"egypt-desc": function ( a, b ) {
    return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}

} );

Answers

  • Loren MaxwellLoren Maxwell Posts: 387Questions: 94Answers: 10
    edited September 2019

    I don't have a direct answer to your question about what's happening during sorting, but maybe using an enumeration would be a better way forward.

    Here's an example: https://datatables.net/blog/2016-06-16

  • egyptdbegyptdb Posts: 3Questions: 1Answers: 0
    edited September 2019

    Hey Loren,

    I'm curious about whether or not a feature of the type-detection code is to stop looking at a string when it notices that one of the mapped values is in the string-- it looks like just the "data-point" is fed into the lookup object-- does that mean that the first letter of the string is fed into the object? Or the whole string? Part of my issue is that strings can be very complex (e.g "wnm sw jrty=ky wr Ax sw jm=f wnm.n sw wnmyt nbjt wr jr=f SAa=s tp=f pH=s Tbtj=f xnfj=s at=f nbt m nAy=s rkHw")-- the sort would have to be able to prioritize strings based on more than just their first letter, or "word" even.

    Also, thanks so much for your answer!!

  • Loren MaxwellLoren Maxwell Posts: 387Questions: 94Answers: 10

    Ah, I hadn't thought it all the way through . . . enumeration obviously isn't the answer for this type of sorting!

    And unfortunately I won't be able to help with the remainder!

  • egyptdbegyptdb Posts: 3Questions: 1Answers: 0

    Thank you for the response in any case!

  • allanallan Posts: 61,740Questions: 1Answers: 10,111 Site admin

    The best option would be to use the Javascript Intl option, but at least in my Chrome / English (GB) browser it doesn't have an egy language support, never mind ancient Egyptian!

    So you probably need to create a plug-in similar to that described here: https://stackoverflow.com/questions/28711653/sorting-string-function-by-custom-alphabet-javascript .

    Allan

This discussion has been closed.