Fixed ASC

This commit is contained in:
dbroqua 2019-04-11 13:20:05 +02:00
parent 38aff94e26
commit 0134087eee

View file

@ -77,7 +77,24 @@ class VegetableTypes {
callback(new Error('Item vegetable type not found'), 404)
return false
}
callback(null, item)
let type = item.toJSON()
let vegetables = []
for (let j = 0; j < type.Vegetables.length; j += 1) {
let k = 0
for (k = 0; k < vegetables.length; k += 1) {
if (type.Vegetables[j].name < vegetables[k].name) {
console.log('Break at:', k)
break
}
}
vegetables.splice(k, 0, type.Vegetables[j])
}
type.Vegetables = vegetables
callback(null, type)
})
.catch((e) => {
callback(e, null)