Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
12-24-2011, 07:01 AM #1
- Join Date
- Dec 2011
- Thanked 0 Times in 0 Posts
Sorting Objects (just for my understanding)
I have an Object, containing an object, containing an object....etc.
So, it's an Object of objects. Not an Array of objects.
And now I want to sort this Object of objects.
Or do I understand it correctly, that I first have to convert the Object to an Array, and than perform an array.sort ?
Tnx in advance for any explanation.
12-24-2011, 08:25 AM #2
- Join Date
- Dec 2004
- the U.S. of freakin' A.
- Thanked 166 Times in 157 Posts
Please see the following links:
Array.sort accepts a callback function that you can use to sort the values in an array...If the values in the array are objects, then you can reference the object properties in your callback function -- and sort by object properties.
So, if you want to use the built in Array.sort feature, you'll have to convert one or more of your objects into arrays.
Of course, I don't see why you couldn't write your own sorting function for objects, and perhaps add the function to the Object prototype.Regards, R.J.
Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Get free updates about new software version releases, features, and bug fixes!
♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪