Sort Array by Parity

Easy
Arrays Array Sorting

Return array with even numbers first, then odd. Print space-separated.

Constraints

1 ≤ nums.length ≤ 5000

Examples

Example 1:
Input: 3 1 2 4
Output: 2 4 3 1
Example 2:
Input: 0
Output: 0
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.