Search Results

Search found 1 results on 1 pages for 'user2259784'.

Page 1/1 | 1 

  • Bubble sort dropped images based on their names

    - by user2259784
    I have written a simple bubble sort function that sort an array of Image objects based on image names. For some reason my function is not swapping the elements of array when needed ( basically new assignment is not working) Here is my code : listOfFiles = event.dataTransfer.files; sortImages(listOfFiles); function sortImages(listOfFiles) { var re = /[0-9]/; var temp; for( var index=0; index < listOfFiles.length ; index++) { for ( var index2=0; index2 < listOfFiles.length-1 ; index2++) { var one = parseFloat(re.exec(listOfFiles[index2].name )); var two = parseFloat(re.exec(listOfFiles[index2+1].name)); console.log(one + " : " + two); if (one > two) { console.log(listOfFiles[index2+1]); console.log(listOfFiles[index2]); //following three lines don't work temp = listOfFiles[index2+1]; listOfFiles[index2+1] = listOfFiles[index2]; listOfFiles[index2] = temp; console.log(listOfFiles[index2+1]); console.log(listOfFiles[index2]); } } } }

    Read the article

1