4
I have an array questions[] with the following properties:
perguntas[0] = { id:1; ordem: 3; inicio: 1 };
perguntas[1] = { id:2; ordem: 2; inicio: 0 };
perguntas[2] = { id:3; ordem: 1; inicio: 1 };
I would like to exchange them order in the array according to the start property. Where 1 must come before 0.
I already use a function to sort according to the order property, only that this sort would be secondary, giving priority to items with the start property marked as 1.
How can I do that?
The expected result would be:
perguntas[0] = { id:3; ordem: 1; inicio: 1 };
perguntas[1] = { id:1; ordem: 3; inicio: 1 };
perguntas[2] = { id:2; ordem: 2; inicio: 0 };
Is this the order you expect, or is it 3/1/2? Or is it 3/1 or 1/3?
– bfavaretto
@bfavaretto When the AP speaks of "order according to property order", I assume it is in ascending order, in the absence of any indication to the contrary. The expected result would therefore be correct.
– mgibsonbr
That may be, but I was confused by what is said in the first half of the question. I don’t know if the array given there has passed the current sort function or not. @mgibsonbr
– bfavaretto