Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting a FileList object

I am trying to sort input files using the new File API. The list that it returns seems to be immutable:

var x = "";
var files = e.target.files; // FileList object
// Loop through the FileList and render image files as thumbnails.

files.sort();

> Uncaught TypeError: Object #<FileList> has no method 'sort' 

If I want to read in multiple files at once, but I want them to arrive in order. (A.csv is processed before B.csv, etc). Is this achievable?

like image 282
Dara Java Avatar asked Apr 15 '13 16:04

Dara Java


1 Answers

[].slice.call(files) to make it into a real array, then you can use .sort on it.

like image 171
Jan Jongboom Avatar answered Nov 07 '22 01:11

Jan Jongboom