4 ms·
Oh, come on, the solution is trivial.
by enedil 8y ago
Oh, come on, the solution is trivial.
- emmanuel_1234 8y agoSo trivial that I can't really see what's there to abstract. It's literally a one liner in Python. [x for x in my_list if x % 2 == 0] + [x for x in my_list if x % 2 != 0]
- codingdave 8y agoThat doesn't re-build it into a linked list as his example showed. It also does multiple passes through the data, which should be fun if there are millions of items. It is a great question for talking about performance tuning an algorithm, but just seems bizarre to be pushing for abstraction on this problem.
- ldd 8y agoMaybe something like lambda f: [x for x in my_list if f(x)] + [x for x in my_list if not f(x)]