Separate a list into even-indexed and odd-indexed parts
Python, 23 bytes
lambda x:x[::2]+x[1::2]
Try it online
Pyth, 5
o~!ZQ
Try it online, or run a Test Suite
Explanation
o~!ZQ ## implicit: Z = 0; Q = eval(input)
o Q ## sort Q using a supplied function
~!Z ## Use the old value of Z, then set Z to be not Z
## This assigns a weight to each number in the list, for example given [0,1,2,3,4]
## This will give (value, weight) = [(0,0), (1,1), (2,0), (3,1), (4,0)]
## The values are sorted by weight and then by index
## This happens because Pyth is written in Python, which performs stable sorts
CJam, 7 bytes
{2/ze_}
Pushes a block (the closest thing to an unnamed function) which transforms the top stack element as required.
Test it here.
Explanation
The explanation assumes that the top of the stack is the array [0 1 2 3 4]
. The actual values don't affect the computation.
2/ e# Split the array into chunks of two: [[0 1] [2 3] [4]]
z e# Zip/transpose, which works on ragged arrays: [[0 2 4] [1 3]]
e_ e# Flatten the result: [0 2 4 1 3]