Question:I have an
hashand what I want to achieve is to sort the
idinside each hash) based on the sort that is in the array and if the
hash) doesn’t exist in
my_array, they should not be deleted and just be pushed down in the sort.
my_arrayfrom that given in the question and have renamed the array to something more appropriate.
Below I’ve listed the arrays used by
sort_byfor each element of
[type, x]is the array
sort_byuses for sorting, it will put all elements for which
type 0before those for which
type = 1. To break ties it orders elements by
type = 1,
xis the index of the element, which keeps them in order at the end.
If you have better answer, please add a comment about this, thank you!