Setting Values from array

Setting Values from array

Hi,
 
I have a dropdown and 2 labels in my aspx page. I am trying to fill the dropdown and the label using jquery.
 
I have used the below code:
 
  1. //Declared Globally
    var testarray = [];
    var fileDescription = "";
    var imagePath = "";
    var Title ="";
  2. $(document).ready(function () {
    while loop  //values added to each item
    {
    testarray.push(Title) + "$~@" + imagePath + "$~@" + fileDescription);
    }
    SortArray();
    });
  3. function SortArray() {
    var ddlImg = this.document.getElementById("ddlImages");
      
        ddlImg.options.length = 0;
        if (testarray.length > 0) {
  4.         testarray.sort(function (a, b) {
                var a1 = a[1], b1 = b[1];
                if (a1 == b1) return 0;
                return a1 > b1 ? 1 : -1;
            });
  5.         for (var i = 0; i < testarray.length; i++) {
                var newArray = testarray[i].split('$~@');
                for (var j = 0; j < newArray.length; j++) {
                  
    ddlImg.options[ddlImg.options.length] = new Option
  6. (newArray[j], newArray[j]);
                   
                   fileDescription = newArray[j];
                  
                   imgfilename = newArray[j];
                    $(".Imageholder").attr("src", imgfilename);
                }           
            }
        }

}

The above code is not working.. array[0] contains like  Tester$~@FileURL$~@testdata
each item in array would be like the above one. It can also have null in the 2nd and 3rd.
 
I am trying to sort the data and assign the first value in dropdown, 2nd value in image holder, 3rd value in file description. Split is based on "$~@"
 
Example data:  
 
How to fix this?
Thanks