having problem sorting repeated Strings,
and here\'s my code..
i successfully sorted the first array but in the second (with repeated strings) it seems not
Change
if (names.length > 2) {
with
if (names.length >= 2) {
output
Ara
Bubbles
Chan
Cristine
Darryl
Inasal
Jollibee.
Kitty
Kring
Madonna
Maria
Matang
Miley
Minnie
Panda
Rose
Soliel
Zoom-zoom
Why not just concatenate the two arrays (String ClassOne and ClassTwo) into one and then call a MergeSort on one array? Your process makes the program more ambiguous in my opinion.
Just change this:
if (names.length > 2)
to
if (names.length > 1)
mergeSort
runs recursively spliting the array into two halves, then merges them and return back up the call chain. When the length of the array passed to mergeSort
is <= 1 it considers the array sorted, this is called the base case.