Generate the Temple Skyline Sequence Consider the following process:

Take some non-negative integer N.
e.g. N = 571

Express it in binary with no leading zeroes. (Zero itself is the only exception, becoming 0.)
e.g. 571 = 1000111011 in binary

Break apart consecutive runs of ones and zeroes in this binary representation.
e.g. 1000111011 → 1, 000, 111, 0, 11

Sort the runs from longest to shortest.
e.g. 1, 000, 111, 0, 11 → 000, 111, 11, 1, 0

Overwrite all the digits in each run with alternating 1's and 0's, always starting with 1's.
e.g. 000, 111, 11, 1, 0 → 111, 000, 11, 0, 1

Concatenate the result to get a new binary number.
e.g. 111, 000, 11, 0, 1 → 1110001101 = 909 in decimal


When you plot the values produced by this process you get a pretty neat graph:

And it's hopefully apparent why I'm calling the resulting sequence the Temple Skyline sequence:

Challenge
Write a program or function that takes in a non-negative integer N and prints or returns the corresponding Temple Skyline sequence number. Your input and output should both be in decimal.
e.g. If the input is 571 the output should be 909.
The shortest code in bytes wins.
For reference, here are the terms in the sequence from N = 0 to 20:
0   1
1   1
2   2
3   3
4   6
5   5
6   6
7   7
8   14
9   13
10  10
11  13
12  12
13  13
14  14
15  15
16  30
17  29
18  26
19  25
20  26

Here are the terms from 0 to 1023.
CJam, 25 23 22 bytes

ri1e&gt;2be`z($W%a\+ze~2b


Just a bit of run-length encoding. -1 thanks to @MartinBüttner.

Try it online / Test suite.

Explanation

ri        Read n from input as int
1e&gt;       Take max with 1 (special case for n = 0)
2b        Convert n to binary
e`        Run length encode
z         Zip, giving a pair [&lt;counts&gt; &lt;10101.. array&gt;]
($W%      Drop the counts array and sort decending
a\+z      Add it back to the 10101.. array and re-zip
e~        Run length decode
2b        Convert from binary