/**
 * Fonction de tri d'un tableau.
 * Tri simple et pas trés performant, mais économe en taille.
 * arrayToSort : le tableau à trier
 * predicate : Prédicat de tri : méthode du type comparer(objet1, objet2) qui rend 0,1,-1.
 */
function sortArray(arrayToSort, predicate)
{
	var newArray = new Array();
	for(var i=0; i<arrayToSort.length; i++)
	{
		var min = i;
		for(var j=i; j<arrayToSort.length; j++)
		{
			if(predicate(arrayToSort[j], arrayToSort[min]) < 0)
			{
				min = j;
			}
		}

		if(min != i)
		{
			newArray.push(arrayToSort[min]);
			arrayToSort[min] = arrayToSort[i];
		}
		else
		{
			newArray.push(arrayToSort[i]);
		}
	}

	return newArray;
}
