﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3620	_ArraySort on 2D is not stable but the documentation says it is	anonymous	Melba23	"_ArraySort claims to be stable in its in-script documentation if you look at the ""modified"" header.


{{{
LazyCoder - added $iSubItem option;
Tylo - implemented stable QuickSort algo;
Jos - changed logic to correctly Sort arrays with mixed Values and Strings;
Melba23 - implemented stable pivot algo
}}}

If you want to sort 2D arrays then the help file tells you that only quick- or insert-sort is used on these (a closer look on the Array.au3 shows you that only quicksort is used).

But if you sort with this code for example you will see that the array tells you that [5, Cherry] comes before [3, Cherry] where it should be the other way round since this algorithm is supposed to be stable.
Stable algorithms do not change the order of items if they equal the compared value.

If you look at the !__ArrayQuickSort2D inside of the Array.au3 you will see that elements are swapped if $L is less or equal than $R. (l. 1813 commented with ; Swap on 3.3.14.2)

First the array is sorted on its first column showing that [3, Cherry] comes before [5, Cherry] and then you can see that after sorting the second column they are switched.

Code to reproduce:
{{{
#include <Array.au3>

Local $aTestArray[5][2] = [[5, ""Cherry""], [4, ""Banana""], [3, ""Cherry""], [2, ""Orange""], [1, ""Apple""]]

;Sort the whole array ascending on the first column
_ArraySort($aTestArray, 0, 0, 0, 0)
_ArrayDisplay($aTestArray)

;Sort the whole array descending on the second column
_ArraySort($aTestArray, 0, 0, 0, 1)
_ArrayDisplay($aTestArray)
}}}

This also happens on the 3.3.14.5."	Bug	closed	3.3.15.3	Documentation	3.3.14.2	None	Completed	_ArraySort Stablity	
