<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Reorder a given array such that all even elements are placed before odd elements.
arr = [1, 2, 3, 4, 5, 6, 7, 8]<|im_end|>
<|im_start|>assistant
def reorder_array(arr):
    """Reorders a given array such that all even elements are placed before odd elements."""
    even = [i for i in arr if i % 2 == 0]
    odd = [j for j in arr if j % 2 != 0]

    return even + odd

if __name__ == '__main__':
    arr = [1, 2, 3, 4, 5, 6, 7, 8]
    ordered = reorder_array(arr)
    print(ordered)<|im_end|>
