Stop Canonical Ordering of Output List
alternatives = N19 | N560 | N41 | N61 | N551 | N20 | N539;
You can map Cases
over the list of alternatives:
Join @@ Cases[{#, __}][m] & /@ (List @@ alternatives);
TableForm @ %
Alternatively, sort the output of Cases
by the position in alternatives
of the first column elements:
SortBy[PositionIndex[List @@ alternatives]@*First][Cases[m, {alternatives, __}]];
% // TableForm
The cases will be found in the order they occur in m
. If each case is unique, as in the example, the following can be used:
Sort[
Cases[m, {N19 | N560 | N41 | N61 | N551 | N20 | N539, __}]
][[Ordering[N19 | N560 | N41 | N61 | N551 | N20 | N539]]]