public void ParallelSort(TwoDimensionConstants by)
    {
        DynamicUniqueStore <K> keys   = Map.Keys;
        DynamicStore <V>       values = Map.Values;

        Int32[] sortedIndices = new Int32[Map.Length];
        if (by == TwoDimensionConstants.KEY)
        {
            DynamicUniqueStore <K> originalKeys = new DynamicUniqueStore <K>();
            for (Int32 i = 0; i < Map.Length; i++)
            {
                originalKeys.Add(keys.Get(i));
            }
            ParallelKeySorter = new ItemParallelSorter <K>(Map.Keys.Items);
            Map.Keys.Items    = ParallelKeySorter.MergeSort(0, Map.Length - 1);
            for (Int32 i = 0; i < Map.Length; i++)
            {
                sortedIndices[i] = originalKeys.GetIndex(keys.Get(i));
            }
            DynamicStore <V> sortedValues = new DynamicStore <V>();
            for (Int32 j = 0; j < Map.Length; j++)
            {
                sortedValues.Add(values.Get(sortedIndices[j]));
            }
            Map.Values = sortedValues;
        }
        else if (by == TwoDimensionConstants.VALUE)
        {
            DynamicStore <V> originalValues = new DynamicStore <V>();
            for (Int32 i = 0; i < Map.Length; i++)
            {
                originalValues.Add(values.Get(i));
            }
            ParallelValueSorter = new ItemParallelSorter <V>(Map.Values.Items);
            Map.Values.Items    = ParallelValueSorter.MergeSort(0, Map.Length - 1);
            for (Int32 i = 0; i < Map.Length; i++)
            {
                sortedIndices[i] = originalValues.GetIndex(values.Get(i));
            }
            DynamicUniqueStore <K> sortedKeys = new DynamicUniqueStore <K>();
            for (Int32 j = 0; j < Map.Length; j++)
            {
                sortedKeys.Add(keys.Get(sortedIndices[j]));
            }
            Map.Keys = sortedKeys;
        }
    }
 public OneDimensionSorter(ItemStore <T> newStore)
 {
     Store          = newStore;
     SingularSorter = new ItemSingularSorter <T>(Store.Items);
     ParallelSorter = new ItemParallelSorter <T>(Store.Items);
 }