March 12, 2012

Sorting Images by File Name

Question by user1259527

I want help arranging images. I have this table and I want the images to appear in a certain order, eg B A G D…. (going from left to right).

The code can be found here.

Answer by Starx

See this answer. This is what you might be asking.

I create a perfect modification of that function for you

function sorter(selector, order) {
    selector.each(function() {
        if(order) {
            for(var i =0; i < order.length; i++){                     
               $("#sorted").append($(this).children('img[id='+order[i]+']'));                
            }
        }

    });
}
sorter($("div"), ['a','c','d']);

Check it out

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!