Closed kerphi closed 8 years ago
I'm suspecting this line to cast arrays into simple objects.
D'accord avec toi, ce n'est pas naturel (et il ne doit pas être facile d'obtenir ce qu'on veut, après ça).
Pourtant, sort n'a l'air défini que sur des tableaux, pas sur des objets (bon, un tableau est un objet). En castant l'objet en tableau, ça correspond bien.
Array({
"0": {
"name": "abcd"
},
"1": {
"name": "zert"
}
});
sort
is defined because Object.create()
copies the properties from the array to the new object.
Assuming sort / sortBy are only meant to be used on arrays, wouldn't it be simpler to check the type with Array.isArray()
and use obj.slice().sort()
?
no solution yet , but the origin :https://github.com/tj/ejs/blob/master/lib/filters.js#L61
object2array : https://github.com/Inist-CNRS/node-jbj/pull/22
I would have just cast the Object to an Array, but this works too.
Now that it's been fixed, this documentation is correct.
Mais je ne mets pas directement dans master car ça ne fonctionne pas comme je l'attendais. En sortie on a étrangement ceci :