/*
Copyright 2011, 2012 Frederic Langlet
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may obtain a copy of the License at

                http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kanzi.util.sort;

import kanzi.ArrayComparator;


public final class DefaultArrayComparator implements ArrayComparator
{
    private final int[] array;
    
    
    public DefaultArrayComparator(int[] array)
    {
        if (array == null)
            throw new NullPointerException("Invalid null array parameter");
        
        this.array = array;
    }
    
    
    
    public int compare(int lidx, int ridx)
    {
        return this.array[lidx] - this.array[ridx];
    }
}
@@ -1019,14 +1019,17 @@
     
-return
+int res =
  thi
@@ -1062,15 +1062,137 @@
 %5Bridx%5D;%0A
+        %0A        // Make the sort stable%0A        if (res == 0)%0A           res = lidx - ridx;%0A        %0A        return res;%0A
     %7D%0A%7D

Modify the default implementation to render the sort stable (QuickSort may use this comparator)