private int partition(int[] arrayIn, int lhs, int rhs, SorterParams.SortDirection sortDir)
    {
        int pivot = arrayIn[lhs + (rhs - lhs) / 2];
        int i = lhs;
        int j = rhs;
        
        MemoryUsage.addMem(3);
        
        while(i <= j)
        {
            if(sortDir == SorterParams.SortDirection.ASCENDING)
            {
                while(arrayIn[i] < pivot)
                {
                    i++;
                }
                while(arrayIn[j] > pivot)
                {
                    j--;
                }
            }
            else
            {
                while(arrayIn[i] > pivot)
                {
                    i++;
                }
                while(arrayIn[j] < pivot)
                {
                    j--;
                }
            }
            if(i <= j)
            {
                Swap(arrayIn, i, j);
                i++;
                j--;
            }
        }
        MemoryUsage.removeMem(3);
        return i;
    }