Guest User

Untitled

a guest
Jan 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public static function sortByField(source:Array, propertyName:String, isDescending:Boolean = false):void {
  2. var numItems:uint = source.length;
  3. var i:uint;
  4. var isSorting:Boolean = true;
  5. while (isSorting) {
  6. isSorting = false;
  7. for (i = 0; i < numItems - 1; i++) {
  8. if ((!isDescending && source[i][propertyName] > source[i + 1][propertyName]) || (isDescending && source[i][propertyName] < source[i + 1][propertyName])) {
  9. var temp:Object = source[i];
  10. source[i] = source[i + 1];
  11. source[i + 1] = temp;
  12. isSorting = true;
  13. }
  14. }
  15. }
  16. }
Add Comment
Please, Sign In to add comment