Sorting excluding articles (The, La, Los, Der…)

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Using Tap Forms Sorting excluding articles (The, La, Los, Der…)

Viewing 1 reply thread
  • Author
    Posts
  • July 7, 2024 at 9:16 AM #50895

    David Gilbert
    Participant

    There is at least one previous post about this topic, to get records not to sort by articles, where writing a script is suggested.
    I have a music title database with titles in many languages, so getting the sorting right is important. I’m thinking of setting up two fields, a display title and a sorting title. The records would sort by the sorting title:
    Étoile
    Jahsager
    Man in the High Castle

    But the form would only include the display title, and so the sort would appear like this.
    L’Étoile
    Der Jahsager
    The Man in the High Castle

    Not like this:
    Der Jahsager
    L’Étoile
    The Man in the High Castle

    It’s a lot of work to do this obviously, so I’m checking to make sure there is no other easy solution. Also, I guess this will work?
    Muchas gracias,
    David

    July 7, 2024 at 4:13 PM #50901

    Brendan
    Keymaster

    Hi David,

    You could do this with a Script Field. Something like this:

    function Sortable_Title() {
    var title = record.getFieldValue('fld-3b1b39ccf20f43e583fe66b8aaa0602c');
    var sortableTitle;
    
    if (title.startsWith('A ')) {
    sortableTitle = title.substring(2);
    
    } else if (title.startsWith('An ')) {
    sortableTitle = title.substring(3);
    
    } else if (title.startsWith('The ')) {
    sortableTitle = title.substring(4);
    
    } else {
    sortableTitle = title;
    }
    
    // console.log(sortableTitle);
    
    return sortableTitle;
    
    }
    
    Sortable_Title();
    You could enhance it to support other article words if you like.
    Thanks,
    Brendan
    • This reply was modified 2 months ago by Brendan.
Viewing 1 reply thread

You must be logged in to reply to this topic.