Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function sortByField(source:Array, propertyName:String, isDescending:Boolean = false):void {
- var numItems:uint = source.length;
- var i:uint;
- var isSorting:Boolean = true;
- while (isSorting) {
- isSorting = false;
- for (i = 0; i < numItems - 1; i++) {
- if ((!isDescending && source[i][propertyName] > source[i + 1][propertyName]) || (isDescending && source[i][propertyName] < source[i + 1][propertyName])) {
- var temp:Object = source[i];
- source[i] = source[i + 1];
- source[i + 1] = temp;
- isSorting = true;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment