mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(commander) changeOrder
This commit is contained in:
parent
668c51d250
commit
f8be93f8c4
1 changed files with 5 additions and 20 deletions
|
|
@ -185,33 +185,18 @@
|
|||
|
||||
|
||||
function changeOrder(json) {
|
||||
var i, n,
|
||||
files = [],
|
||||
dirs = [],
|
||||
current = [],
|
||||
var files = [],
|
||||
dirs = [],
|
||||
sorted = [];
|
||||
|
||||
n = json.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
current = json[i];
|
||||
|
||||
json.forEach(function(current) {
|
||||
if (current.size === 'dir')
|
||||
dirs.push(current);
|
||||
else
|
||||
files.push(current);
|
||||
}
|
||||
});
|
||||
|
||||
n = dirs.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
current = dirs[i];
|
||||
sorted.push(current);
|
||||
}
|
||||
|
||||
n = files.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
current = files[i];
|
||||
sorted.push(current);
|
||||
}
|
||||
sorted = dirs.concat(files);
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue