Javascript - Handling "The" When Sorting an Array -


i'm asking question quality check myself , see if more experienced javascript coders might have better approach...

i have array of titles, of begin "the". don't want "the" taken account when sorting titles. planned approach use regex cut "the" beginning of value splice onto end of value before sorting array. example, modify "the right stuff" "right stuff, the".

my question: there better/more efficient way of doing iterating through array , making regex modifications?

edit: took time respond (and sorry delay). played around both methods (regex cut , splice comparison). ended going comparison route fit best flow of script.

you write custom comparison function can pass sorting algorithm returns appropriate value when compares strings have 'the' @ beginning , string doesn't. in other cases, use natural ordering. once have such function, simple matter sort strings them.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -