JSFiddle - React, Tailwind, and code Playground
by cgtrman
HTML
<ul id="filelist">
</ul>
JavaScript
// Assign jQuery var to element with ID 'filelist'
var $the_ul = $("#filelist");
var $obj_win_top_get_files = {
110: "013_904_general.docx",
111: "013_902_info.docx",
112: "013_120_list.docx",
109: "013_110_otter.docx"
}
var arr_ids_filenames = [];
// convert your file list into an array of objects
$.each($obj_win_top_get_files, function(key, name) {
// use key:pair format
arr_ids_filenames.push({
key: key,
name: name
});
});
// sort by file name (and not by key/id)
arr_ids_filenames.sort(function(a, b) {
return ((a.name < b.name) ? -1 : ((a.name > b.name) ? 1 : 0));
});
// add items to list
$.each(arr_ids_filenames, function(index, file) {
$the_ul.append('<li id="chk_file_' + file.key + '">' + file.name + '</li>')
});