# Javascript version of AS2's Array.sortOn() method

**URL:** <https://forum.kirupa.com/t/javascript-version-of-as2s-array-sorton-method/287345>\
**Category:** Uncategorized\
**Created:** [April 29, 2009, 5:57pm UTC](https://forum.kirupa.com/t/javascript-version-of-as2s-array-sorton-method/287345 "2009-04-29T17:57:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iomega\_zippy](https://avatars.discourse-cdn.com/v4/letter/i/5fc32e/32.png) [@iomega\_zippy](https://forum.kirupa.com/u/iomega_zippy)\
**Post date:** [April 29, 2009, 5:57pm UTC](https://forum.kirupa.com/t/javascript-version-of-as2s-array-sorton-method/287345/1 "2009-04-29T17:57:56Z")

</div>

I have an array of objects and I’m looking for a Javascript prototype (or something) that will work as nicely as AS2’s Array.sortOn() method, namely being able to pass it an array of object keys to sort and sub sort on, and a matching array of type of sort (ascending, descending, numeric, or a combo of those).

Current use in AS2 functionality test:

```auto
var totalArr:Array = [];

function addEntry(rating:Number, importance:Number) {
	totalArr.push({competency: competencyNum, total: (11 - rating) * importance, rating: rating , importance: importance});
	totalArr.sortOn(["total", "rating", "importance"], [Array.NUMERIC|Array.DESCENDING, Array.NUMERIC, Array.NUMERIC|Array.DESCENDING]);
}

```
