Array.sort unexpected behavior

I have an array of strings called “term_array”. When I sort it using this line:

term_array.sort(Array.CASEINSENSITIVE);

…it does a pretty good job of sorting it alphabetically, with one problem:

“human being” precedes “human”
“holy mackerel” precedes “holy”
etc.

Standard alphabetization works the opposite way – if a word is identical but has more letters at the end of it, then it is supposed to come after the shorter word.

Is there some reason that this works this way? Does anyone know if there is a workaround? I tried monkeying with the parameters with no luck. I started reading up on the “compareFunction” parameter, but can’t wrap my head around how you would use it to remedy this.

Any insight would be much appreciated.