F
fox_fire
The API documentation for the Arrays class sort(Object[] a,
Comparator c) method says:
"The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the lowest
element in the high sublist). "
I believe this is causing a problem with my program. It uses this method
to quickly sort a rather LARGE array of words (somewhere around 20,000)
into an order specified by a comparator. I use a Comparator because I sort
the words based on only one of the characters (by position 2, for
instance), not lexicographically.
The API says it won't merge the last time "if the highest element in the
low sublist is less than the lowest element in the high sublist." Well, I
keep getting output that is separated into 2 large, sorted groups of
words. It didn't seem to perform the last merge because it fit the
criteria above. I don't understand _WHY_ the sort method makes this
exception. The thing isn't sorted completely if you don't perform the last
merge, even if the bottom and top elements of the two lists are in order.
Comparator c) method says:
"The sorting algorithm is a modified mergesort (in which the merge is
omitted if the highest element in the low sublist is less than the lowest
element in the high sublist). "
I believe this is causing a problem with my program. It uses this method
to quickly sort a rather LARGE array of words (somewhere around 20,000)
into an order specified by a comparator. I use a Comparator because I sort
the words based on only one of the characters (by position 2, for
instance), not lexicographically.
The API says it won't merge the last time "if the highest element in the
low sublist is less than the lowest element in the high sublist." Well, I
keep getting output that is separated into 2 large, sorted groups of
words. It didn't seem to perform the last merge because it fit the
criteria above. I don't understand _WHY_ the sort method makes this
exception. The thing isn't sorted completely if you don't perform the last
merge, even if the bottom and top elements of the two lists are in order.