kguler already showed the primary methods so here are some secondary ones.
One for fun:
a = Range@10;
Reap[Sow[#, #~Mod~2] & /@ a, {0, 1}][[2, All, 1]]
{{2, 4, 6, 8, 10}, {1, 3, 5, 7, 9}}
And one for performance:
a = RandomInteger[1*^7, 1*^7];
With[{mask = BitAnd[a, 1]},
{a[[ SparseArray[mask, Automatic, 1]["AdjacencyLists"] ]],
a[[ SparseArray[mask]["AdjacencyLists"] ]]}
] // Timing // First
0.234
kguler's fastest method for comparison:
GatherBy[a, OddQ] // Timing // First
0.406
A fast method from Rojo for Mathematica versions 8+ (Pick
was optimized after v7):
With[{mask = BitAnd[a, 1]}, Pick[a, mask, #] & /@ {0, 1}]
Cases
andSelect
. $\endgroup$