Sahra: Array nach dir und Dateinamen sortieren

Beitrag lesen

Oh Mann .... ahhhhh .... Wald Bäume

jetzt gehts

  
var files =  fs.readdirSync(dir)  
        .map(function(v) {return { name:v};  
        })  
        .sort(function(a, b) {  
            if(a.name.search(/\./) == b.name.search(/\./)){  
                console.log('Case1',a,b);  
                return a.name - b.name  
            }  
            if(b.name.search(/\./) != -1){  
                console.log('Case2',a,b,b.name.search(/\./));  
                return -1  
            }  
            if(a.name.search(/\./) != -1){  
                console.log('Case3',a,b);  
                return 1  
            }  
        }  
        ).map(function(v) { return v.name; });