PDA

View Full Version : sorting image objects in an array



trollger
13 Nov 2010, 12:13 AM
Hi every one I am having some technical difficulties with my java script, maybe I should just go get some :sleeping: Its getting late.

Any way... I am trying to use the sort function in an image object inside another array. So the code I have so far that is relevant to my problem is as follows.


function compareABC(a, b) {
return b.src - a.src;
}

categories[CATOGORY].IMGS = categories[CATOGORY].IMGS.sort(compareABC(a,b));

CATEGORY is a user generated string that allows organization of the images. IMGS is an array inside the CATEGORY array. Please tell me why this is not sorting my images properly according to there src element.

Any help would be appreciated, I would really like to implement this feature in my image gallery.

If you need more information to help me solve this problem please let me know.

ps (I don't entirely understand how the sort function works)

thanks for reading.