You are given a huge integer $a$ consisting of $n$ digits ($n$ is between $1$ and $3 \cdot 10^5$, inclusive). It may contain leading zeros.

You can swap two digits on adjacent (neighboring) positions if the swapping digits are of different parity (that is, they have different remainders when divided by $2$). 

For example, if $a = 032867235$ you can get the following integers in a single operation:   $302867235$ if you swap the first and the second digits;  $023867235$ if you swap the second and the third digits;  $032876235$ if you swap the fifth and the sixth digits;  $032862735$ if you swap the sixth and the seventh digits;  $032867325$ if you swap the seventh and the eighth digits. 

Note, that you can't swap digits on positions $2$ and $4$ because the positions are not adjacent. Also, you can't swap digits on positions $3$ and $4$ because the digits have the same parity.

You can perform any number (possibly, zero) of such operations.

Find the minimum integer you can obtain.

Note that the resulting integer also may contain leading zeros.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases in the input.

The only line of each test case contains the integer $a$, its length $n$ is between $1$ and $3 \cdot 10^5$, inclusive.

It is guaranteed that the sum of all values $n$ does not exceed $3 \cdot 10^5$.


-----Output-----

For each test case print line — the minimum integer you can obtain.


-----Example-----
Input
3
0709
1337
246432

Output
0079
1337
234642



-----Note-----

In the first test case, you can perform the following sequence of operations (the pair of swapped digits is highlighted): $0 \underline{\textbf{70}} 9 \rightarrow 0079$.

In the second test case, the initial integer is optimal. 

In the third test case you can perform the following sequence of operations: $246 \underline{\textbf{43}} 2 \rightarrow 24 \underline{\textbf{63}}42 \rightarrow 2 \underline{\textbf{43}} 642 \rightarrow 234642$.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Amortized analysis

Greedy algorithms


Solutions:
for _ in range(int(input())):
	n = input()
	odd = []
	eve = []
	for i in n:
		if int(i) % 2 != 0:
			odd.append(i)
		else:
			eve.append(i)
	i = 0
	j = 0
	while i < len(odd) and j < len(eve):
		if odd[i] < eve[j]:
			print(odd[i], end='')
			i += 1
		else:
			print(eve[j], end='')
			j += 1
	for k in range(i, len(odd)):
		print(odd[k], end='')
	for k in range(j, len(eve)):
		print(eve[k], end='')
	print()


from collections import deque
t = int(input())
while t:
	l = list(map(int, input().strip()))
	e = []
	o = []
	for i in l:
		if i % 2:
			o.append(i)
		else:
			e.append(i)
	i = 0
	j = 0
	res = []
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			res.append(e[i])
			i += 1
		else:
			res.append(o[j])
			j += 1
	while i < len(e):
		res.append(e[i])
		i += 1
	while j < len(o):
		res.append(o[j])
		j += 1
	for i in res:
		print(i, end='')
	print()
	t -= 1


for _ in range(int(input())):
	a = input()
	(f, g) = ('', '')
	for c in a:
		if c in '13579':
			f += c
		else:
			g += c
	f += 'a'
	g += 'a'
	r = ''
	(i, j) = (0, 0)
	while f[i] != 'a' or g[j] != 'a':
		if f[i] < g[j]:
			r += f[i]
			i += 1
		else:
			r += g[j]
			j += 1
	print(r)


Q = int(input())
for q in range(Q):
	s = input()
	chet = []
	nechet = []
	for i in s:
		if int(i) % 2 == 0:
			chet.append(int(i))
		else:
			nechet.append(int(i))
	chet.append(10)
	nechet.append(10)
	i = 0
	j = 0
	ans = []
	while i < len(chet) and j < len(nechet):
		if i == len(chet) - 1 and j == len(nechet) - 1:
			break
		if chet[i] < nechet[j]:
			ans.append(chet[i])
			i += 1
		else:
			ans.append(nechet[j])
			j += 1
	print(*ans, sep='')


t = int(input())
for _ in range(t):
	a = input()
	odd = []
	even = []
	for i in range(len(a)):
		if int(a[i]) % 2 == 0:
			even.append(int(a[i]))
		else:
			odd.append(int(a[i]))
	ans = []
	o_index = 0
	e_index = 0
	while o_index < len(odd) and e_index < len(even):
		if odd[o_index] < even[e_index]:
			ans.append(odd[o_index])
			o_index += 1
		else:
			ans.append(even[e_index])
			e_index += 1
	if o_index < len(odd):
		ans += odd[o_index:]
	else:
		ans += even[e_index:]
	print(''.join(map(str, ans)))


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = fi()
while t > 0:
	t -= 1
	s = si()
	d = [[], []]
	for i in s:
		d[int(i) % 2].append(i)
	i = j = 0
	m1 = len(d[0])
	m2 = len(d[1])
	ans = []
	while i < m1 and j < m2:
		if d[0][i] < d[1][j]:
			ans.append(d[0][i])
			i += 1
		else:
			ans.append(d[1][j])
			j += 1
	print(''.join(ans) + ''.join(d[0][i:]) + ''.join(d[1][j:]))


tests = int(input())
for _ in range(tests):
	x = input()
	ods = []
	evens = []
	for c in x:
		if c == '1' or c == '3' or c == '5' or (c == '7') or (c == '9'):
			ods.append(c)
		else:
			evens.append(c)
	ans = []
	i = 0
	j = 0
	while i < len(ods) and j < len(evens):
		if ods[i] < evens[j]:
			ans.append(ods[i])
			i += 1
		else:
			ans.append(evens[j])
			j += 1
	while i < len(ods):
		ans.append(ods[i])
		i += 1
	while j < len(evens):
		ans.append(evens[j])
		j += 1
	print(''.join(ans))


n = int(input())
for i in range(n):
	even = []
	odd = []
	s = input()
	for j in s:
		if int(j) % 2:
			odd.append(j)
		else:
			even.append(j)
	ans = []
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] > odd[j]:
			ans.append(odd[j])
			j += 1
		else:
			ans.append(even[i])
			i += 1
	ans.extend(even[i:] + odd[j:])
	print(''.join(ans))


for _ in [0] * int(input()):
	l = (x, y) = [[], []]
	i = j = 0
	r = []
	for d in input():
		l[int(d) % 2] += (d,)
	x += (':',)
	y += (':',)
	while x[i] + y[j] < '::':
		if x[i] < y[j]:
			r += (x[i],)
			i += 1
		else:
			r += (y[j],)
			j += 1
	print(''.join(r))


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	S = input()[:-1]
	odds = []
	evens = []
	for s in S:
		if int(s) % 2 == 0:
			evens.append(int(s))
		else:
			odds.append(int(s))
	i_even = 0
	i_odd = 0
	ans = ''
	while i_even < len(evens) and i_odd < len(odds):
		if evens[i_even] >= odds[i_odd]:
			ans += str(odds[i_odd])
			i_odd += 1
		else:
			ans += str(evens[i_even])
			i_even += 1
	if i_even < len(evens):
		for s in evens[i_even:]:
			ans += str(s)
	else:
		for s in odds[i_odd:]:
			ans += str(s)
	print(ans)


from sys import stdin

def main():
	data = stdin.read().splitlines()[1:]
	for (ii, s) in enumerate(data):
		(gf, n) = (([], []), len(s))
		for c in s:
			gf[ord(c) & 1].append(c)
		(g, f) = gf
		g.append('a')
		f.append('a')
		g.reverse()
		f.reverse()
		data[ii] = ''.join((f.pop() if f[-1] < g[-1] else g.pop() for _ in range(n)))
	print('\n'.join(map(str, data)))
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = ri()
	for _ in range(tc):
		s = list(rs())
		ns = list('0123456789')
		e = list('02468')
		o = list('13579')
		de = {}
		do = {}
		for i in e:
			de[i] = 1
		for i in o:
			do[i] = 1
		even = deque([])
		odd = deque([])
		for i in s:
			if i in de:
				even.append(i)
			else:
				odd.append(i)
		ans = []
		while len(ans) != len(s):
			(p, q) = ('a', 'a')
			if len(even) > 0:
				p = even[0]
			if len(odd) > 0:
				q = odd[0]
			if q < p:
				ans.append(q)
				odd.popleft()
			else:
				ans.append(p)
				even.popleft()
		print(''.join(ans))
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from heapq import merge
for T in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(int(i))
		else:
			o.append(int(i))
	l = list(merge(e, o))
	for i in l:
		print(i, end='')
	print('\n', end='')


N = int(input())

def solve():
	s = input()
	even_list = []
	odd_list = []
	acc = ''
	for (i, c) in enumerate(s):
		ci = int(c)
		if ci % 2 == 0:
			even_list.append(c)
		else:
			odd_list.append(c)
	even_ptr = 0
	odd_ptr = 0
	ans = [None for _ in s]
	ans_idx = -1
	while even_ptr != len(even_list) or odd_ptr != len(odd_list):
		ans_idx += 1
		if even_ptr == len(even_list):
			ans[ans_idx] = odd_list[odd_ptr]
			odd_ptr += 1
			continue
		if odd_ptr == len(odd_list):
			ans[ans_idx] = even_list[even_ptr]
			even_ptr += 1
			continue
		if int(even_list[even_ptr]) <= int(odd_list[odd_ptr]):
			ans[ans_idx] = even_list[even_ptr]
			even_ptr += 1
		else:
			ans[ans_idx] = odd_list[odd_ptr]
			odd_ptr += 1
	print(''.join(ans))
for _ in range(N):
	solve()


a = int(input())
while a > 0:
	odd = []
	even = []
	x = input()
	for i in x:
		if int(i) % 2 == 0:
			even.append(int(i))
		else:
			odd.append(int(i))
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			print(even[i], end='')
			i += 1
		else:
			print(odd[j], end='')
			j += 1
	if i == len(even):
		for x in range(j, len(odd)):
			print(odd[x], end='')
	elif j == len(odd):
		for x in range(i, len(even)):
			print(even[x], end='')
	a -= 1
	print()


q = int(input())
for _ in range(q):
	a = list(map(int, list(input())))
	even = [d for d in a if d % 2 == 0]
	odd = [d for d in a if d % 2]
	ei = 0
	oi = 0
	for d in a:
		if ei == len(even) or (oi != len(odd) and even[ei] > odd[oi]):
			print(odd[oi], end='')
			oi += 1
		else:
			print(even[ei], end='')
			ei += 1
	print()


def solve1(s):
	evens = [u for u in s if u % 2 == 0]
	odds = [u for u in s if u % 2 == 1]
	if len(odds) == 0:
		return evens
	ans = []
	inserted_odd = 0
	current_odd = odds[inserted_odd]
	for i in range(len(evens)):
		while current_odd < evens[i] and inserted_odd < len(odds):
			ans.append(current_odd)
			inserted_odd += 1
			if inserted_odd < len(odds):
				current_odd = odds[inserted_odd]
		ans.append(evens[i])
	while inserted_odd < len(odds):
		ans.append(current_odd)
		inserted_odd += 1
		if inserted_odd < len(odds):
			current_odd = odds[inserted_odd]
	return ans

def solve2(s):
	odds = [u for u in s if u % 2 == 0]
	evens = [u for u in s if u % 2 == 1]
	if len(odds) == 0:
		return evens
	ans = []
	inserted_odd = 0
	current_odd = odds[inserted_odd]
	for i in range(len(evens)):
		while current_odd < evens[i] and inserted_odd < len(odds):
			ans.append(current_odd)
			inserted_odd += 1
			if inserted_odd < len(odds):
				current_odd = odds[inserted_odd]
		ans.append(evens[i])
	while inserted_odd < len(odds):
		ans.append(current_odd)
		inserted_odd += 1
		if inserted_odd < len(odds):
			current_odd = odds[inserted_odd]
	return ans
for _ in range(int(input())):
	s = list(map(int, list(input())))
	ans = min(solve1(s), solve2(s))
	print(''.join(map(str, ans)))


R = lambda : list(map(int, input().split()))
(q,) = R()
for w in range(q):
	s = input()
	n = len(s)
	st1 = 0
	st2 = 0
	ch = []
	nech = []
	for i in s:
		if int(i) % 2 == 0:
			ch += [int(i)]
		else:
			nech += [int(i)]
	ch += [100]
	nech += [100]
	for i in range(n):
		if ch[st1] < nech[st2]:
			print(ch[st1], end='')
			st1 += 1
		else:
			print(nech[st2], end='')
			st2 += 1
	print()


for _ in range(int(input())):
	a = list(map(int, input().rstrip()))
	(e, o, n) = ([], [], len(a))
	while a:
		z = a.pop()
		if z % 2:
			o.append(z)
		else:
			e.append(z)
	while e or o:
		if e and o:
			if e[-1] < o[-1]:
				a.append(e.pop())
			else:
				a.append(o.pop())
		elif e:
			a.append(e.pop())
		else:
			a.append(o.pop())
	print(''.join(map(str, a)))


ctt = int(input())
for ct in range(ctt):
	s = input()
	ev = []
	od = []
	for i in s:
		if int(i) % 2 == 0:
			ev.append(int(i))
		else:
			od.append(int(i))
	r = []
	i = 0
	j = 0
	while i < len(ev) and j < len(od):
		if ev[i] < od[j]:
			r.append(ev[i])
			i += 1
		else:
			r.append(od[j])
			j += 1
	for k in range(i, len(ev)):
		r.append(ev[k])
	for k in range(j, len(od)):
		r.append(od[k])
	print(*r, sep='')


for _ in range(int(input())):
	x = list(input())
	(chet, nechet) = ([], [])
	for i in x:
		if int(i) % 2 == 0:
			chet.append(int(i))
		else:
			nechet.append(int(i))
	(c, n, lnc, lnn) = (0, 0, len(chet), len(nechet))
	while c != lnc or n != lnn:
		if c == lnc:
			k = nechet[n]
			n += 1
		elif n == lnn:
			k = chet[c]
			c += 1
		elif nechet[n] < chet[c]:
			k = nechet[n]
			n += 1
		else:
			k = chet[c]
			c += 1
		print(k, end='')
	print()


import sys
input = sys.stdin.readline
Q = int(input())
Query = []
for _ in range(Q):
	S = list(input().rstrip())
	Query.append(S)
for S in Query:
	L = len(S)
	A1 = []
	A2 = []
	for s in S:
		a = int(s)
		if a % 2 == 0:
			A1.append(a)
		else:
			A2.append(a)
	A1 = A1[::-1]
	A2 = A2[::-1]
	ans = []
	while A1 or A2:
		if not A1:
			a = A2.pop()
		elif not A2:
			a = A1.pop()
		elif A1[-1] < A2[-1]:
			a = A1.pop()
		else:
			a = A2.pop()
		ans.append(a)
	print(''.join([str(a) for a in ans]))


import heapq
for _ in range(int(input())):
	s = input()
	(a, b) = ([], [])
	for i in s:
		if int(i) % 2 == 0:
			a.append(i)
		else:
			b.append(i)
	c = list(heapq.merge(a, b))
	print(''.join(c))


t = int(input())
while t:
	s = input()
	(a, b) = ([], [])
	for i in s:
		if int(i) % 2:
			a.append(i)
		else:
			b.append(i)
	i = j = 0
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			print(a[i], end='')
			i += 1
		else:
			print(b[j], end='')
			j += 1
	while i < len(a):
		print(a[i], end='')
		i += 1
	while j < len(b):
		print(b[j], end='')
		j += 1
	print()
	t -= 1


import sys
from typing import List

def proc(s: str):
	odd = []
	even = []
	for e in map(int, list(s.strip())):
		if e % 2 == 1:
			odd.append(e)
		else:
			even.append(e)
	i = j = 0
	r = []
	while i < len(odd) and j < len(even):
		if odd[i] < even[j]:
			r.append(odd[i])
			i += 1
		else:
			r.append(even[j])
			j += 1
	r = r + odd[i:] + even[j:]
	return ''.join(map(str, r))

def solve(n: int, a: List[str]) -> List[str]:
	return [proc(s) for s in a]
input = sys.stdin.readline
n = int(input())
a = [input() for _ in range(n)]
print('\n'.join(solve(n, a)))


import sys
q = int(input())
for case in range(q):
	s = input()
	(o, e) = ([], [])
	for c in s:
		n = ord(c) - ord('0')
		if n & 1:
			o.append(c)
		else:
			e.append(c)
	(i, j) = (0, 0)
	while i < len(o) and j < len(e):
		if o[i] < e[j]:
			print(o[i], end='')
			i += 1
		else:
			print(e[j], end='')
			j += 1
	while i < len(o):
		print(o[i], end='')
		i += 1
	while j < len(e):
		print(e[j], end='')
		j += 1
	print('')


def solve():
	s = input()
	odd = ''
	even = ''
	for i in s:
		if int(i) % 2 == 1:
			even += i
		else:
			odd += i
	p_odd = 0
	p_even = 0
	ans = ''
	while p_odd != len(odd) and p_even != len(even):
		odd_digit = odd[p_odd]
		even_digit = even[p_even]
		if int(even_digit) > int(odd_digit):
			ans += odd_digit
			p_odd += 1
		else:
			ans += even_digit
			p_even += 1
	while p_odd != len(odd):
		ans = ans + odd[p_odd]
		p_odd += 1
	while p_even != len(even):
		ans = ans + even[p_even]
		p_even += 1
	print(ans)
t = int(input())
while t > 0:
	solve()
	t -= 1


n = int(input())
while n != 0:
	n -= 1
	(res, pair, impair) = ('', '', '')
	for i in input():
		if int(i) % 2 == 0:
			pair += i
		else:
			impair += i
	(a, b) = (0, 0)
	while a < len(pair) and b < len(impair):
		if pair[a] < impair[b]:
			res += pair[a]
			a += 1
		else:
			res += impair[b]
			b += 1
	for i in range(a, len(pair)):
		res += pair[i]
	for i in range(b, len(impair)):
		res += impair[i]
	print(res)


from collections import deque
t = int(input())
for __ in [0] * t:
	s = list(input())
	a = [int(e) for e in s]
	n = len(a)
	p = deque([a[0]])
	k = n
	for i in range(1, n):
		if (a[i] + p[-1]) % 2 == 0:
			p.append(a[i])
		else:
			k = i
			break
	res = []
	for i in range(k, n):
		if (a[i] + p[-1]) % 2 == 0:
			p.append(a[i])
		else:
			while (p[0] + a[i]) % 2 == 0:
				res.append(p.popleft())
			rr = n
			for j in range(len(p)):
				if p[j] > a[i]:
					rr = j
					break
			if rr == n:
				for j in range(len(p) - 1):
					res.append(p[j])
				p = deque([p[-1], a[i]])
			else:
				for j in range(rr):
					res.append(p.popleft())
				p.appendleft(a[i])
	for e in p:
		res.append(e)
	ans = [str(e) for e in res]
	print(''.join(ans))


tests = int(input())
for _ in range(tests):
	s = input()
	ch = []
	nech = []
	for i in s:
		if int(i) % 2 == 0:
			ch.append(int(i))
		else:
			nech.append(int(i))
	ch.append(100000)
	nech.append(100000)
	l = 0
	r = 0
	for i in range(len(s)):
		if ch[l] < nech[r]:
			print(ch[l], end='')
			l += 1
		else:
			print(nech[r], end='')
			r += 1
	print()


n = int(input())
for _ in range(n):
	num = list(map(int, list(input())))
	odd = []
	even = []
	for n in num:
		if n % 2 == 0:
			even.append(n)
		else:
			odd.append(n)
	m = len(odd)
	n = len(even)
	i = j = 0
	res = []
	while i < m and j < n:
		if odd[i] < even[j]:
			res.append(odd[i])
			i += 1
		else:
			res.append(even[j])
			j += 1
	if i == m:
		res += even[j:]
	else:
		res += odd[i:]
	print(''.join(list(map(str, res))))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	a = input()[:-1]
	(even, odd) = ([], [])
	for i in range(len(a)):
		num = int(a[i])
		if num % 2 == 0:
			even.append(num)
		else:
			odd.append(num)
	even.append(100)
	odd.append(100)
	(cnt_e, cnt_o) = (0, 0)
	ans = []
	for i in range(len(a)):
		if even[cnt_e] < odd[cnt_o]:
			ans.append(even[cnt_e])
			cnt_e += 1
		else:
			ans.append(odd[cnt_o])
			cnt_o += 1
	print(''.join(map(str, ans)))


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	a = input().rstrip()
	odd = []
	even = []
	for i in a:
		if int(i) % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	ans = []
	i = 0
	j = 0
	while i < len(odd) and j < len(even):
		if odd[i] < even[j]:
			ans.append(odd[i])
			i += 1
		else:
			ans.append(even[j])
			j += 1
	while i < len(odd):
		ans.append(odd[i])
		i += 1
	while j < len(even):
		ans.append(even[j])
		j += 1
	print(''.join(ans))


for _ in range(int(input())):
	s = input()
	le3 = len(s)
	l1 = []
	l2 = []
	for i in s:
		if int(i) % 2:
			l1.append(int(i))
		else:
			l2.append(int(i))
	c1 = 0
	c2 = 0
	ans = ''
	le1 = len(l1)
	le2 = len(l2)
	le = len(l1 + l2)
	while c1 < le1 and c2 < le2:
		if l1[c1] < l2[c2]:
			ans += str(l1[c1])
			c1 += 1
		else:
			ans += str(l2[c2])
			c2 += 1
	if c1 != le1:
		for i in range(c1, le1):
			ans += str(l1[i])
	elif c2 != le2:
		for i in range(c2, le2):
			ans += str(l2[i])
	print('0' * (le3 - len(ans)) + ans)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	s = si()
	eve = []
	odd = []
	for i in s:
		if int(i) % 2 == 0:
			eve.append(int(i))
		else:
			odd.append(int(i))
	i = 0
	j = 0
	ans = []
	while i < len(eve) and j < len(odd):
		if eve[i] < odd[j]:
			ans.append(eve[i])
			i += 1
		else:
			ans.append(odd[j])
			j += 1
	ans.extend(odd[j:])
	ans.extend(eve[i:])
	for i in ans:
		print(i, end='')
	print()


from heapq import merge
for u in range(int(input())):
	k = [[], []]
	for i in input():
		k[int(i) % 2] += i
	print(''.join(merge(*k)))


t = int(input())
for _ in range(t):
	s = input()
	even = ''
	odd = ''
	for i in s:
		if int(i) % 2 == 0:
			even = even + i
		else:
			odd = odd + i
	i = 0
	j = 0
	n = len(even)
	m = len(odd)
	ans = ''
	while i < n and j < m:
		if int(even[i]) < int(odd[j]):
			ans = ans + even[i]
			i = i + 1
		else:
			ans = ans + odd[j]
			j = j + 1
	while i < n:
		ans = ans + even[i]
		i = i + 1
	while j < m:
		ans = ans + odd[j]
		j = j + 1
	print(ans)


import sys
readline = sys.stdin.readline
read = sys.stdin.read
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	s = list(map(int, list(ns())))
	od = list()
	ev = list()
	for x in s:
		if x & 1:
			od.append(x)
		else:
			ev.append(x)
	od = od[::-1]
	ev = ev[::-1]
	res = list()
	while od and ev:
		if od[-1] < ev[-1]:
			res.append(od.pop())
		else:
			res.append(ev.pop())
	res += od[::-1] + ev[::-1]
	print(*res, sep='')
	return
T = ni()
for _ in range(T):
	solve()


t = int(input())
for j in range(t):
	s = input()
	first = []
	second = []
	for i in range(len(s)):
		if int(s[i]) % 2:
			first.append(int(s[i]))
		else:
			second.append(int(s[i]))
	i_f = 0
	i_s = 0
	while i_f < len(first) and i_s < len(second):
		if first[i_f] < second[i_s]:
			print(first[i_f], end='')
			i_f += 1
		else:
			print(second[i_s], end='')
			i_s += 1
	while i_f < len(first):
		print(first[i_f], end='')
		i_f += 1
	while i_s < len(second):
		print(second[i_s], end='')
		i_s += 1
	print()


ans = {}
test = int(input())
for each in range(test):
	num = input()
	n = len(num)
	num = {i: int(num[i]) for i in range(n)}
	output = {}
	even = {}
	odd = {}
	even_count = 0
	odd_count = 0
	for i in range(n):
		if num[i] % 2 == 0:
			even[even_count] = num[i]
			even_count += 1
		else:
			odd[odd_count] = num[i]
			odd_count += 1
	num = {}
	i = 0
	j = 0
	count = 0
	while even and odd:
		output[count] = min(even[i], odd[j])
		if min(even[i], odd[j]) == even[i]:
			del even[i]
			i += 1
		else:
			del odd[j]
			j += 1
		count += 1
	if even:
		for every in range(i, max(even.keys()) + 1):
			output[count] = even[every]
			count += 1
	if odd:
		for every in range(j, max(odd.keys()) + 1):
			output[count] = odd[every]
			count += 1
	outputs = [str(output[me]) for me in range(max(output.keys()) + 1)]
	ans[each] = ''.join(outputs)
for each in range(test):
	print(ans[each])


t = int(input())
for _ in range(t):
	s = list(map(int, list(input())))
	ans = []
	l = len(s)
	arr = [[], []]
	for i in range(l):
		arr[s[i] % 2].append(s[i])
	l = 0
	r = 0
	while l < len(arr[0]) and r < len(arr[1]):
		if arr[0][l] < arr[1][r]:
			ans.append(arr[0][l])
			l += 1
		else:
			ans.append(arr[1][r])
			r += 1
	while l < len(arr[0]):
		ans.append(arr[0][l])
		l += 1
	while r < len(arr[1]):
		ans.append(arr[1][r])
		r += 1
	print(''.join(list(map(str, ans))))


import sys
mod = int(1000000000.0 + 7)
input = sys.stdin.readline
test = int(input())
for t in range(test):
	s = input().strip()
	odd = []
	even = []
	for k in range(len(s)):
		p = int(s[k])
		if p % 2 == 1:
			odd += [p]
		else:
			even += [p]
	n1 = len(odd)
	n2 = len(even)
	(i, j) = (0, 0)
	while i < n1 or j < n2:
		p1 = 10
		p2 = 10
		if i < n1:
			p1 = odd[i]
		if j < n2:
			p2 = even[j]
		if p1 < p2:
			print(p1, end='')
			i += 1
		else:
			print(p2, end='')
			j += 1
	print()


import sys
t = int(input())
for i in range(t):
	n = list(sys.stdin.readline())[:-1]
	odd = []
	even = []
	e = ['0', '2', '4', '6', '8']
	for j in n:
		if j in e:
			even.append(j)
		else:
			odd.append(j)
	op = []
	x = len(n)
	a = 0
	b = 0
	al = len(odd)
	bl = len(even)
	for j in range(x):
		if a < al and b < bl:
			if even[b] >= odd[a]:
				print(odd[a], end='')
				a += 1
			else:
				print(even[b], end='')
				b += 1
		else:
			break
	op = op + odd[a:] + even[b:]
	for j in range(a, al):
		print(odd[j], end='')
	for j in range(b, bl):
		print(even[j], end='')
	print()


t = int(input())
while t > 0:
	t -= 1
	p = input()
	p = list(p)
	a = []
	b = []
	for i in range(len(p)):
		if int(p[i]) % 2:
			a.append(p[i])
		else:
			b.append(p[i])
	d = [0 for i in range(len(p))]
	i = 0
	j = 0
	c = []
	while i < len(a) and j < len(b):
		if int(a[i]) > int(b[j]):
			c.append(b[j])
			j += 1
		else:
			c.append(a[i])
			i += 1
	print(''.join(c), end='')
	print(''.join(b[j:]), end='')
	print(''.join(a[i:]), end='')
	print()


T = int(input())
for t in range(T):
	inp = input().strip()
	oddlist = []
	evenlist = []
	for ch in inp:
		num = int(ch)
		if num % 2 == 0:
			evenlist.append(num)
		else:
			oddlist.append(num)
	n0 = len(evenlist)
	n1 = len(oddlist)
	out = ''
	i = 0
	j = 0
	while i < n1 and j < n0:
		if oddlist[i] < evenlist[j]:
			out += str(oddlist[i])
			i += 1
		else:
			out += str(evenlist[j])
			j += 1
	while i < n1:
		out += str(oddlist[i])
		i += 1
	while j < n0:
		out += str(evenlist[j])
		j += 1
	print(out)


t = int(input())
for i in range(t):
	s = input()
	even = []
	odd = []
	ans = ''
	for x in s:
		if int(x) % 2 == 0:
			even += [int(x)]
		else:
			odd += [int(x)]
	ind1 = 0
	ind2 = 0
	while ind1 != len(even) and ind2 != len(odd):
		if even[ind1] > odd[ind2]:
			ans += str(odd[ind2])
			ind2 += 1
		else:
			ans += str(even[ind1])
			ind1 += 1
	while ind1 != len(even):
		ans += str(even[ind1])
		ind1 += 1
	while ind2 != len(odd):
		ans += str(odd[ind2])
		ind2 += 1
	print(ans)


t = int(input())
for tt in range(t):
	s = input().strip()
	even = []
	odd = []
	for i in s:
		if int(i) % 2 == 0:
			even.append(int(i))
		else:
			odd.append(int(i))
	ans = ''
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] <= odd[j]:
			ans += str(even[i])
			i += 1
		else:
			ans += str(odd[j])
			j += 1
	while i < len(even):
		ans += str(even[i])
		i += 1
	while j < len(odd):
		ans += str(odd[j])
		j += 1
	print(ans)


import heapq
from sys import stdin
input = stdin.readline

def f(n):
	ar = list(map(int, list(n)))
	q = [[], []]
	for i in ar:
		q[i % 2].append(i)
	q[0] = q[0][::-1]
	q[1] = q[1][::-1]
	ans = []
	while q[0] or q[1]:
		if q[0] == []:
			ans += q[1][::-1]
			break
		if q[1] == []:
			ans += q[0][::-1]
			break
		if q[0][-1] < q[1][-1]:
			ans.append(q[0].pop(-1))
		elif q[1][-1] < q[0][-1]:
			ans.append(q[1].pop(-1))
	return ans
for i in range(int(input())):
	s = input().strip()
	print(*f(s), sep='')


for i in range(int(input())):
	s = input()
	ans = ''
	e = list(filter(lambda i: int(i) % 2 == 1, s))
	o = list(filter(lambda i: int(i) % 2 == 0, s))
	i = j = 0
	while i < len(e) or j < len(o):
		if len(e) == i:
			ans += o[j]
			j += 1
			continue
		if len(o) == j:
			ans += e[i]
			i += 1
			continue
		if o[j] < e[i]:
			ans += o[j]
			j += 1
		else:
			ans += e[i]
			i += 1
	print(ans)


def solve():
	s = input()
	evens = []
	odds = []
	for c in s:
		i = int(c)
		if i % 2 == 0:
			evens.append(i)
		else:
			odds.append(i)
	(i, j) = (0, 0)
	final = []
	while True:
		if i == len(evens):
			final += odds[j:]
			break
		elif j == len(odds):
			final += evens[i:]
			break
		elif evens[i] < odds[j]:
			final.append(evens[i])
			i += 1
		else:
			final.append(odds[j])
			j += 1
	print(''.join(map(str, final)))
n = int(input())
for _ in range(n):
	solve()


for _ in range(int(input())):
	n = input()
	e = []
	o = []
	for c in n:
		if c in '02468':
			e.append(c)
		else:
			o.append(c)
	e.reverse()
	o.reverse()
	arr = []
	while e and o:
		if e[-1] < o[-1]:
			arr.append(e.pop())
		else:
			arr.append(o.pop())
	e.reverse()
	o.reverse()
	arr += e
	arr += o
	print(''.join(arr))


import bisect
import functools
import math
import sys
from collections import defaultdict
from itertools import groupby
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	t = ri()
	for _ in range(t):
		s = input()
		n = len(s)
		odd = []
		even = []
		for c in s:
			x = int(c)
			if x % 2 == 0:
				even.append(x)
			else:
				odd.append(x)
		(posOdd, posEven) = (0, 0)
		while posOdd < len(odd) or posEven < len(even):
			if posOdd < len(odd) and posEven < len(even):
				if odd[posOdd] < even[posEven]:
					print(odd[posOdd], end='')
					posOdd += 1
				else:
					print(even[posEven], end='')
					posEven += 1
			elif posOdd < len(odd):
				print(odd[posOdd], end='')
				posOdd += 1
			else:
				print(even[posEven], end='')
				posEven += 1
		print()
main()


import sys
from collections import deque
readline = sys.stdin.readline
t = int(readline())
for _ in range(t):
	s = str(readline())
	e = []
	o = []
	for i in range(len(s) - 1):
		if ord(s[i]) % 2 == 0:
			o.append(s[i])
		else:
			e.append(s[i])
	news = []
	i = 0
	j = 0
	le = len(e)
	lo = len(o)
	if le == 0 or lo == 0:
		sys.stdout.write(s)
		continue
	while True:
		if i == le:
			for q in range(j, lo, 1):
				news.append(o[q])
			break
		if j == lo:
			for q in range(i, le, 1):
				news.append(e[q])
			break
		if ord(e[i]) < ord(o[j]):
			news.append(e[i])
			i += 1
		else:
			news.append(o[j])
			j += 1
	for qq in news:
		sys.stdout.write(qq)
	sys.stdout.write('\n')


t = int(input())
for _ in range(t):
	ev = []
	od = []
	s = map(int, list(input()))
	for v in s:
		if v % 2:
			od.append(v)
		else:
			ev.append(v)
	ev.append(1000)
	od.append(1000)
	ep = 0
	op = 0
	while ep < len(ev) - 1 or op < len(od) - 1:
		if ev[ep] < od[op]:
			print(ev[ep], end='')
			ep += 1
		else:
			print(od[op], end='')
			op += 1
	print('')


from collections import deque

def solve():
	a = input()
	odd = deque()
	even = deque()
	for i in a:
		if int(i) % 2:
			odd.append(i)
		else:
			even.append(i)
	ans = []
	while odd or even:
		if odd and even:
			if odd[0] < even[0]:
				ans.append(odd.popleft())
			else:
				ans.append(even.popleft())
		elif odd:
			ans.append(odd.popleft())
		else:
			ans.append(even.popleft())
	print(''.join(ans))
t = int(input())
for i in range(t):
	solve()


import sys
input = sys.stdin.readline
from collections import deque
t = int(input())
while t != 0:
	n = input().strip()
	q1 = []
	q2 = []
	for i in range(len(n)):
		if int(n[i]) % 2 == 0:
			q1.append(n[i])
		else:
			q2.append(n[i])
	n1 = len(q1)
	n2 = len(q2)
	ans = ''
	i = 0
	j = 0
	while i < n1 and j < n2:
		if int(q1[i]) < int(q2[j]):
			print(q1[i], end='')
			i += 1
		else:
			print(q2[j], end='')
			j += 1
	while i < n1:
		print(q1[i], end='')
		i += 1
	while j < n2:
		print(q2[j], end='')
		j += 1
	print()
	t -= 1


import sys
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for i in range(int(ri())):
	s = ri()
	odd = []
	even = []
	for i in s:
		if int(i) % 2 == 0:
			even.append(int(i))
		else:
			odd.append(int(i))
	(i, j) = (0, 0)
	ans = []
	while i < len(even) and j < len(odd):
		if odd[j] < even[i]:
			ans.append(odd[j])
			j += 1
		else:
			ans.append(even[i])
			i += 1
	while j < len(odd):
		ans.append(odd[j])
		j += 1
	while i < len(even):
		ans.append(even[i])
		i += 1
	print(''.join(map(str, ans)))


t = int(input())
for _ in range(t):
	o = []
	e = []
	s = str(input())
	a = [int(x) for x in s]
	for i in a:
		if i & 1:
			o.append(i)
		else:
			e.append(i)
	i = 0
	j = 0
	ans = []
	(n, m) = (len(o), len(e))
	while i < n and j < m:
		if o[i] < e[j]:
			ans.append(o[i])
			i += 1
		else:
			ans.append(e[j])
			j += 1
	while i < n:
		ans.append(o[i])
		i += 1
	while j < m:
		ans.append(e[j])
		j += 1
	print(''.join(map(str, ans)))


from heapq import *
for _ in [0] * int(input()):
	l = [[], []]
	for d in input():
		l[int(d) % 2] += (d,)
	print(''.join(merge(*l)))


t = int(input())
for i in range(t):
	nums = list(map(int, list(input())))
	(nums0, nums1) = ([], [])
	for num in nums:
		if num % 2 == 0:
			nums0.append(str(num))
		else:
			nums1.append(str(num))
	nums0.append(str(99))
	nums1.append(str(99))
	(p0, p1) = (0, 0)
	(l0, l1) = (len(nums0) - 1, len(nums1) - 1)
	ans = str()
	while p0 < l0 or p1 < l1:
		p0_prev = p0
		while p0 < l0 and nums0[p0] < nums1[p1]:
			p0 += 1
		ans += ''.join(nums0[p0_prev:p0])
		p1_prev = p1
		while p1 < l1 and nums1[p1] < nums0[p0]:
			p1 += 1
		ans += ''.join(nums1[p1_prev:p1])
	print(ans)


for _ in range(int(input())):
	s = input()
	a = []
	b = []
	ans = []
	for i in s:
		if int(i) % 2 == 0:
			a.append(i)
		else:
			b.append(i)
	i = 0
	j = 0
	while i < len(a) and j < len(b):
		if a[i] > b[j]:
			ans.append(b[j])
			j += 1
		else:
			ans.append(a[i])
			i += 1
	ans += a[i:] + b[j:]
	print(''.join(ans))


from collections import deque
t = int(input())
for i in range(t):
	n = list(map(int, input()))
	(chet, nechet) = (deque(), deque())
	for el in n:
		if el % 2 == 0:
			chet.append(el)
		else:
			nechet.append(el)
	ans = []
	while chet or nechet:
		if chet and nechet:
			if chet[0] < nechet[0]:
				ans.append(chet.popleft())
			else:
				ans.append(nechet.popleft())
		elif chet:
			ans.append(chet.popleft())
		else:
			ans.append(nechet.popleft())
	print(''.join(map(str, ans)))


t = int(input())
for tc in range(t):
	s = input()
	odd = []
	even = []
	for el in s:
		if int(el) % 2 == 0:
			even.append(el)
		else:
			odd.append(el)
	i = 0
	j = 0
	res = []
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			res.append(even[i])
			i += 1
		else:
			res.append(odd[j])
			j += 1
	if i < len(even):
		res.extend(even[i:])
	if j < len(odd):
		res.extend(odd[j:])
	print(''.join(res))


for _ in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(int(i))
		else:
			o.append(int(i))
	i = 0
	j = 0
	ans = ''
	while i < len(e) or j < len(o):
		if i == len(e):
			ans += str(o[j])
			j += 1
			continue
		if j == len(o):
			ans += str(e[i])
			i += 1
			continue
		if e[i] < o[j]:
			ans += str(e[i])
			i += 1
		else:
			ans += str(o[j])
			j += 1
	print(ans)


def solve(s):
	e = []
	o = []
	for i in range(len(s)):
		if s[i] % 2 == 0:
			e.append(s[i])
		else:
			o.append(s[i])
	(i, j) = (0, 0)
	res = []
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			res.append(e[i])
			i += 1
		else:
			res.append(o[j])
			j += 1
	if i == len(e):
		left = o[j:len(o)]
	else:
		left = e[i:len(e)]
	res = ''.join(map(str, res)) + ''.join(map(str, left))
	print(res)
t = int(input())
for _ in range(t):
	s = list(input())
	s = list(map(int, s))
	solve(s)


for _ in range(int(input())):
	s = input()
	a = [[int(i) for i in s if int(i) % 2 == 0] + [10], [int(i) for i in s if int(i) % 2 == 1] + [10]]
	i = j = 0
	res = []
	while not a[0][i] == a[1][j] == 10:
		if a[0][i] < a[1][j]:
			res.append(str(a[0][i]))
			i += 1
		else:
			res.append(str(a[1][j]))
			j += 1
	print(''.join(res))


for _ in range(int(input())):
	a = list(input())
	b = []
	s = []
	i = 0
	for x in a:
		if i >= len(s) or (s[-1] in '02468') == (x in '02468'):
			s += (x,)
		else:
			while i < len(s) and s[i] < x:
				b += (s[i],)
				i += 1
			if i < len(s):
				b += (x,)
			else:
				s += (x,)
	b += s[i:]
	print(''.join(b))


q = int(input())
for _ in range(q):
	num = list(map(int, input()))
	even = list(filter(lambda x: x % 2 == 0, num))
	odd = list(filter(lambda x: x % 2 == 1, num))
	if len(even) >= 1 and len(odd) >= 1:
		output = []
		e = 0
		o = 0
		while e < len(even) and o < len(odd):
			if even[e] < odd[o]:
				output.append(even[e])
				e += 1
			else:
				output.append(odd[o])
				o += 1
		while e < len(even):
			output.append(even[e])
			e += 1
		while o < len(odd):
			output.append(odd[o])
			o += 1
		print(''.join(map(str, output)))
	else:
		print(''.join(map(str, num)))


te = int(input())
while te > 0:
	te -= 1
	num = list(input())
	n = len(num)
	evens = []
	odds = []
	for i in num:
		if int(i) & 1 == 1:
			odds.append(i)
		else:
			evens.append(i)
	ans = ''
	i = 0
	j = 0
	while i < len(evens) and j < len(odds):
		if int(evens[i]) < int(odds[j]):
			ans += evens[i]
			i += 1
		else:
			ans += odds[j]
			j += 1
	if i == len(evens):
		while j < len(odds):
			ans += odds[j]
			j += 1
	elif j == len(odds):
		while i < len(evens):
			ans += evens[i]
			i += 1
	print(ans)


from collections import deque
import sys
tcs = int(input())
for _ in range(tcs):
	num = list(map(int, list(str(sys.stdin.readline().rstrip()))))
	odd = deque()
	even = deque()
	for i in range(len(num)):
		if num[i] % 2 == 0:
			even.append(num[i])
		else:
			odd.append(num[i])
	res = []
	while len(odd) != 0 and len(even) != 0:
		if odd[0] < even[0]:
			res.append(odd.popleft())
		else:
			res.append(even.popleft())
	while len(odd) != 0:
		res.append(odd.popleft())
	while len(even) != 0:
		res.append(even.popleft())
	for i in range(len(res)):
		print(res[i], end='')
	print()


for _ in range(int(input())):
	s = input()
	(e, o) = ([], [])
	for i in s:
		if int(i) % 2 == 0:
			e.append(i)
		else:
			o.append(i)
	(i, j) = (0, 0)
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			print(e[i], end='')
			i += 1
		else:
			print(o[j], end='')
			j += 1
	while i < len(e):
		print(e[i], end='')
		i += 1
	while j < len(o):
		print(o[j], end='')
		j += 1
	print()


for rpt in range(int(input())):
	a = input()
	evens = []
	odds = []
	for i in a:
		i = int(i)
		if i % 2 == 0:
			evens.append(i)
		else:
			odds.append(i)
	x = 0
	y = 0
	res = ''
	while x < len(evens) and y < len(odds):
		if evens[x] < odds[y]:
			res += str(evens[x])
			x += 1
		else:
			res += str(odds[y])
			y += 1
	if x < len(evens):
		for i in range(x, len(evens)):
			res += str(evens[i])
	else:
		for i in range(y, len(odds)):
			res += str(odds[i])
	print(res)


t = int(input())
for _ in range(t):
	A = str(input())
	A = list(A)
	A = [int(d) for d in A]
	n = len(A)
	O = []
	E = []
	for a in A:
		if a % 2 == 0:
			E.append(a)
		else:
			O.append(a)
	E.reverse()
	O.reverse()
	ans = []
	while E and O:
		e = E.pop()
		o = O.pop()
		if e < o:
			ans.append(str(e))
			O.append(o)
		else:
			ans.append(str(o))
			E.append(e)
	if E:
		E.reverse()
		for e in E:
			ans += str(e)
	if O:
		O.reverse()
		for o in O:
			ans += str(o)
	print(''.join(ans))


import sys
t = int(input())
for ti in range(t):
	s = input()
	odd = []
	even = []
	for c in s:
		if int(c) % 2 == 0:
			even.append(c)
		else:
			odd.append(c)
	res = []
	i = 0
	j = 0
	for _ in range(len(s)):
		if i >= len(even):
			res.append(odd[j])
			j += 1
		elif j >= len(odd):
			res.append(even[i])
			i += 1
		elif odd[j] < even[i]:
			res.append(odd[j])
			j += 1
		else:
			res.append(even[i])
			i += 1
	print(''.join(res))


import sys
from collections import deque
input = sys.stdin.readline
q = int(input())
s = [input() for i in range(q)]
for i in range(q):
	a0 = deque([])
	a1 = deque([])
	for j in range(len(s[i]) - 1):
		tmp = int(s[i][j])
		if tmp % 2 == 0:
			a0.append(tmp)
		else:
			a1.append(tmp)
	ans = []
	while True:
		if a0 and a1:
			if a0[0] > a1[0]:
				tmp = a1.popleft()
				ans.append(tmp)
			else:
				tmp = a0.popleft()
				ans.append(tmp)
		else:
			while a0:
				tmp = a0.popleft()
				ans.append(tmp)
			while a1:
				tmp = a1.popleft()
				ans.append(tmp)
			break
	print(''.join(map(str, ans)))


t = int(input())
for i in range(t):
	odd_list = []
	even_list = []
	integer = input()
	for element in integer:
		if int(element) % 2 == 0:
			even_list.append(int(element))
		else:
			odd_list.append(int(element))
	odd_num = 0
	even_num = 0
	ans = []
	while odd_num < len(odd_list) and even_num < len(even_list):
		if odd_list[odd_num] > even_list[even_num]:
			ans.append(even_list[even_num])
			even_num += 1
		else:
			ans.append(odd_list[odd_num])
			odd_num += 1
	ans += odd_list[odd_num:] + even_list[even_num:]
	print(''.join((str(i) for i in ans)))


import sys
from collections import deque
input = sys.stdin.readline
t = int(input().strip())
for _ in range(t):
	s = input().strip()
	n = len(s)
	o = deque([])
	e = deque([])
	for i in range(n):
		if int(s[i]) % 2 == 0:
			e.append(s[i])
		else:
			o.append(s[i])
	ans = []
	for i in range(n):
		if len(e) == 0:
			ans.append(o[0])
			o.popleft()
			continue
		if len(o) == 0:
			ans.append(e[0])
			e.popleft()
			continue
		if e[0] < o[0]:
			ans.append(e[0])
			e.popleft()
		else:
			ans.append(o[0])
			o.popleft()
	print(''.join(ans))


q = int(input())
for t in range(q):
	s = input()
	ch = []
	nch = []
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			ch.append(int(s[i]))
		else:
			nch.append(int(s[i]))
	ans = []
	i1 = 0
	i2 = 0
	while i1 < len(ch) and i2 < len(nch):
		if ch[i1] < nch[i2]:
			ans.append(ch[i1])
			i1 += 1
		else:
			ans.append(nch[i2])
			i2 += 1
	while i2 < len(nch):
		ans.append(nch[i2])
		i2 += 1
	while i1 < len(ch):
		ans.append(ch[i1])
		i1 += 1
	for i in range(len(ans)):
		print(ans[i], end='')
	print()


for __ in range(int(input())):
	a = list(map(int, input()))
	lst1 = [elem for elem in a if elem % 2 == 0]
	lst2 = [elem for elem in a if elem % 2 != 0]
	result = list()
	(i, j) = (0, 0)
	while i < len(lst1) and j < len(lst2):
		if lst1[i] < lst2[j]:
			result.append(lst1[i])
			i += 1
		else:
			result.append(lst2[j])
			j += 1
	if i < len(lst1):
		for h in range(i, len(lst1)):
			result.append(lst1[h])
	if j < len(lst2):
		for h in range(j, len(lst2)):
			result.append(lst2[h])
	print(''.join(map(str, result)))


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
q = int(input())
while q:
	s = list(map(str, input().strip()))
	i = 0
	j = 0
	ans = []
	odd = []
	even = []
	for i in s:
		if (ord(i) - ord('0')) % 2:
			odd.append(i)
		else:
			even.append(i)
	i = 0
	j = 0
	while i < len(odd) or j < len(even):
		if i < len(odd) and j < len(even):
			if ord(odd[i]) > ord(even[j]):
				ans.append(even[j])
				j += 1
			else:
				ans.append(odd[i])
				i += 1
		elif i < len(odd):
			ans.append(odd[i])
			i += 1
		else:
			ans.append(even[j])
			j += 1
	print(''.join(ans))
	q -= 1


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))

def solve():
	nums = [int(i) for i in input().strip()]
	odds = []
	evens = []
	(lodd, leven) = (0, 0)
	for num in nums:
		if num % 2 == 1:
			odds.append(num)
			lodd += 1
		else:
			evens.append(num)
			leven += 1
	odds.append(100)
	evens.append(100)
	(io, ie) = (0, 0)
	ans = []
	while True:
		if odds[io] < evens[ie]:
			ans.append(odds[io])
			io += 1
			if io == lodd:
				ans += evens[ie:leven]
				break
		else:
			ans.append(evens[ie])
			ie += 1
			if ie == leven:
				ans += odds[io:lodd]
				break
	print(''.join(list(map(str, ans))))
	return

def main():
	t = getN()
	for times in range(t):
		solve()
main()


q = int(input())
for _ in range(q):
	d = input()
	a = []
	b = []
	for el in d:
		n = int(el)
		if n % 2 == 0:
			a.append(n)
		else:
			b.append(n)
	res = []
	i = 0
	j = 0
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			res.append(str(a[i]))
			i += 1
		else:
			res.append(str(b[j]))
			j += 1
	if i < len(a):
		res.extend([str(e) for e in a[i:]])
	else:
		res.extend([str(e) for e in b[j:]])
	print(''.join(res))


n = int(input())

def main():
	Ss = input()
	ki = ''
	gu = ''
	for s in Ss:
		if int(s) % 2 == 0:
			gu += s
		else:
			ki += s
	if len(gu) == 0:
		return ki
	elif len(ki) == 0:
		return gu
	else:
		ans = ''
		ind_gu = 0
		ind_ki = 0
		while ind_gu < len(gu) or ind_ki < len(ki):
			if ind_gu == len(gu):
				ans += ki[ind_ki]
				ind_ki += 1
			elif ind_ki == len(ki):
				ans += gu[ind_gu]
				ind_gu += 1
			elif int(gu[ind_gu]) < int(ki[ind_ki]):
				ans += gu[ind_gu]
				ind_gu += 1
			else:
				ans += ki[ind_ki]
				ind_ki += 1
		return ans
for _ in range(n):
	ans = main()
	print(ans)


n = int(input())
for i in range(n):
	l = list(map(int, input()))
	a = [k for k in l[::-1] if k % 2]
	b = [k for k in l[::-1] if not k % 2]
	ans = []
	while a and b:
		if a[-1] < b[-1]:
			ans.append(a.pop())
		else:
			ans.append(b.pop())
	if a:
		ans.extend(a[::-1])
	elif b:
		ans.extend(b[::-1])
	print(''.join(map(str, ans)))


import os

def smallest(s):
	groups = [[], []]
	for c in s:
		groups[int(c) % 2].append(c)
	groups = [g[::-1] for g in groups]
	r = []
	while True:
		if groups[0] and groups[1]:
			if groups[0][-1] < groups[1][-1]:
				r.append(groups[0].pop(-1))
			else:
				r.append(groups[1].pop(-1))
		elif groups[0] and (not groups[1]):
			return r + groups[0][::-1]
		elif groups[1] and (not groups[0]):
			return r + groups[1][::-1]
		else:
			return r

def pp(input):
	n_test = int(input())
	for i in range(n_test):
		print(''.join(smallest(input())))
if 'paalto' in os.getcwd():
	from string_source import string_source
	s1 = string_source('3\n0709\n1337\n246432\n')
	pp(s1)
else:
	pp(input)


T = int(input())
for t in range(T):
	s = str(input())
	n = len(s)
	even = []
	odd = []
	arr = []
	for i in range(n):
		if int(s[i]) % 2 == 0:
			even.append(int(s[i]))
		else:
			odd.append(int(s[i]))
	j = 0
	k = 0
	for i in range(n):
		if j == len(odd):
			arr.append(even[k])
			k += 1
			continue
		if k == len(even):
			arr.append(odd[j])
			j += 1
			continue
		if odd[j] < even[k]:
			arr.append(odd[j])
			j += 1
		else:
			arr.append(even[k])
			k += 1
	for i in range(n):
		print(arr[i], end='')
	print('')


from itertools import groupby
for _ in range(int(input())):
	s = input()
	n = len(s)
	i = j = 0
	while i < n or j < n:
		while i < n and int(s[i]) % 2:
			i += 1
		while j < n and (not int(s[j]) % 2):
			j += 1
		if i == j == n:
			break
		if i < n and (j == n or s[i] < s[j]):
			print(end=s[i])
			i += 1
		else:
			print(end=s[j])
			j += 1
	print()


import sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	A = [int(a) for a in input()]
	N = len(A)
	O = []
	E = []
	for i in range(N):
		if A[i] % 2:
			O.append(A[i])
		else:
			E.append(A[i])
	O = O[::-1]
	E = E[::-1]
	B = []
	while O or E:
		if not O:
			B.append(E.pop())
		elif not E:
			B.append(O.pop())
		elif O[-1] < E[-1]:
			B.append(O.pop())
		else:
			B.append(E.pop())
	print(''.join(map(str, B)))


n = int(input())
lst_of_cases = []
for i in range(n):
	case = str(input())
	lst_of_cases.append(case)

def divide(i, sp, sn):
	for j in i:
		if int(j) % 2 == 0:
			sp += j
		else:
			sn += j
	return (sp, sn)

def unite(i, sp, sn, output):
	p = 0
	n = 0
	for j in range(len(i)):
		if len(sp) == p:
			output += sn[n:]
			break
		elif len(sn) == n:
			output += sp[p:]
			break
		elif int(sp[p]) < int(sn[n]):
			output += sp[p]
			p += 1
		elif int(sn[n]) < int(sp[p]):
			output += sn[n]
			n += 1
	return output
for i in lst_of_cases:
	sp = ''
	sn = ''
	(sp, sn) = divide(i, sp, sn)
	output = ''
	print(unite(i, sp, sn, output))


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	for _ in range(int(input())):
		a = list(map(int, input().rstrip()))
		(e, o, n) = ([], [], len(a))
		while a:
			z = a.pop()
			if z % 2:
				o.append(z)
			else:
				e.append(z)
		while e or o:
			if e and o:
				if e[-1] < o[-1]:
					a.append(e.pop())
				else:
					a.append(o.pop())
			elif e:
				a.append(e.pop())
			else:
				a.append(o.pop())
		print(''.join(map(str, a)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	L = [int(x) for x in input()]
	N = len(L)
	E = []
	O = []
	for i in L:
		if i & 1:
			O.append(i)
		else:
			E.append(i)
	o = 0
	e = 0
	ans = []
	for i in range(N):
		if o != len(O) and e != len(E):
			if O[o] < E[e]:
				ans.append(O[o])
				o += 1
			else:
				ans.append(E[e])
				e += 1
		elif o == len(O):
			ans.append(E[e])
			e += 1
		elif e == len(E):
			ans.append(O[o])
			o += 1
	print(''.join([str(i) for i in ans]))


import sys
import itertools
import math
import collections
from collections import Counter

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def getm(ts, n, used):
	m = -1
	for i in range(n):
		if used[i] == 0:
			if m == -1 or len(ts[i]) > len(ts[m]):
				m = i
	return m
t = ii()
for _ in range(t):
	s = input()
	o = []
	e = []
	for i in s:
		v = int(i)
		if v % 2:
			o.append(v)
		else:
			e.append(v)
	res = []
	i = j = 0
	while i < len(o) and j < len(e):
		if o[i] < e[j]:
			res.append(o[i])
			i += 1
		else:
			res.append(e[j])
			j += 1
	while i < len(o):
		res.append(o[i])
		i += 1
	while j < len(e):
		res.append(e[j])
		j += 1
	prr(res, '')


import sys
import math
from queue import *
from collections import *
mod = int(1000000000.0 + 7)
input = sys.stdin.readline
ii = lambda : list(map(int, input().strip().split()))
ist = lambda : list(input().strip())
test = int(input())
for t in range(test):
	s = input().strip()
	odd = []
	even = []
	for k in range(len(s)):
		p = int(s[k])
		if p % 2 == 1:
			odd += [p]
		else:
			even += [p]
	n1 = len(odd)
	n2 = len(even)
	(i, j) = (0, 0)
	while i < n1 or j < n2:
		p1 = 10
		p2 = 10
		if i < n1:
			p1 = odd[i]
		if j < n2:
			p2 = even[j]
		if p1 < p2:
			print(p1, end='')
			i += 1
		else:
			print(p2, end='')
			j += 1
	print()


from math import inf
import sys
q = int(input())
input = sys.stdin.readline
for i in range(q):
	s = [int(x) for x in list(input()[:-1])]
	a = []
	b = []
	c = d = 0
	for item in s:
		if item % 2 == 0:
			a.append(item)
			c += 1
		else:
			b.append(item)
			d += 1
	a.append(inf)
	b.append(inf)
	k = j = 0
	tot = ''
	while k + j <= c + d + 10:
		if a[j] < b[k]:
			tot += str(a[j])
			j += 1
		elif b[k] < a[j]:
			tot += str(b[k])
			k += 1
		else:
			break
	print(tot)


import sys
input = sys.stdin.readline
from collections import deque
t = int(input())
for _ in range(t):
	a = input().rstrip()
	n = len(a)
	even = deque()
	odd = deque()
	for i in range(n):
		if int(a[i]) % 2:
			odd.append(int(a[i]))
		else:
			even.append(int(a[i]))
	ans = []
	while even and odd:
		e = even.popleft()
		o = odd.popleft()
		if e > o:
			ans.append(o)
			even.appendleft(e)
		else:
			ans.append(e)
			odd.appendleft(o)
	if even:
		ans.extend(even)
	elif odd:
		ans.extend(odd)
	print(*ans, sep='')


for _ in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		if int(i) % 2:
			o.append(int(i))
		else:
			e.append(int(i))
	o.reverse()
	e.reverse()
	ans = []
	while e and o:
		if e[-1] < o[-1]:
			ans.append(e.pop())
		else:
			ans.append(o.pop())
	if e:
		while e:
			ans.append(e.pop())
	else:
		while o:
			ans.append(o.pop())
	print(''.join(map(str, ans)))


for _ in range(int(input())):
	n = list(map(int, input()))
	(e, o) = ([], [])
	for i in n:
		if i % 2:
			o.append(i)
		else:
			e.append(i)
	(i, j) = (0, 0)
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			print(e[i], end='')
			i += 1
		else:
			print(o[j], end='')
			j += 1
	if i < len(e):
		print(*e[i:], sep='')
	else:
		print(*o[j:], sep='')


t = int(input())
for k in range(0, t):
	s = input()
	l1 = ''
	l2 = ''
	for i in s:
		if int(i) % 2 == 0:
			l1 = l1 + i
		else:
			l2 = l2 + i
	out = ''
	i = 0
	j = 0
	len1 = len(l1)
	len2 = len(l2)
	if l1 == '':
		out = l2
	elif l2 == '':
		out = l1
	else:
		while True:
			if l1[i] < l2[j]:
				out = out + l1[i]
				i += 1
				if i == len1:
					out = out + l2[j:]
					break
			else:
				out = out + l2[j]
				j += 1
				if j == len2:
					out = out + l1[i:]
					break
				if l2[j] == 9:
					out = out + l1[i:] + l2[j:]
					break
	print(out)


def main():
	answer = ''
	for query in range(int(input())):
		_num = input()
		even_digits = ''
		odd_digits = ''
		for letter in _num:
			if int(letter) % 2 == 0:
				even_digits += letter
			else:
				odd_digits += letter
		new_num = ''
		(i, j) = (0, 0)
		while i < len(even_digits) or j < len(odd_digits):
			if i >= len(even_digits):
				new_num += odd_digits[j:]
				break
			elif j >= len(odd_digits):
				new_num += even_digits[i:]
				break
			elif even_digits[i] < odd_digits[j]:
				new_num += even_digits[i]
				i += 1
			else:
				new_num += odd_digits[j]
				j += 1
		answer += new_num + '\n'
	print(answer)
main()


queries = int(input())
for x in range(queries):
	num = input()
	oddlist = []
	evenlist = []
	result = ''
	oddindex = 0
	evenindex = 0
	for x in num:
		if int(x) % 2 == 0:
			evenlist.append(x)
		else:
			oddlist.append(x)
	a = len(evenlist)
	b = len(oddlist)
	while True:
		if a == evenindex:
			print(''.join(oddlist[oddindex:]), end='\n')
			break
		elif b == oddindex:
			print(''.join(evenlist[evenindex:]), end='\n')
			break
		print(str(min(int(oddlist[oddindex]), int(evenlist[evenindex]))), end='')
		if min(oddlist[oddindex], evenlist[evenindex]) == oddlist[oddindex]:
			oddindex += 1
		else:
			evenindex += 1
	print(result)


t = int(input())
for _ in range(t):
	a = list(input())
	lo = []
	le = []
	for i in range(len(a)):
		if int(a[i]) % 2 == 1:
			lo.append(a[i])
		else:
			le.append(a[i])
	r = ''
	e = 0
	o = 0
	leno = len(lo)
	lene = len(le)
	while o != leno or e != lene:
		if o == leno:
			r += le[e]
			e += 1
		elif e == lene:
			r += lo[o]
			o += 1
		elif le[e] <= lo[o]:
			r += le[e]
			e += 1
		else:
			r += lo[o]
			o += 1
	print(r)


import heapq
for _ in range(int(input())):
	ar = input()
	odd = []
	even = []
	ans = ''
	for i in range(len(ar)):
		if int(ar[i]) % 2 == 0:
			even.append(ar[i])
		else:
			odd.append(ar[i])
	li = list(heapq.merge(odd, even))
	print(''.join(li))


import sys, os, io
input = sys.stdin.readline
for _ in range(int(input())):
	s = input().strip()
	s = [int(i) for i in s]
	odd = []
	even = []
	for i in s:
		if i % 2:
			odd.append(i)
		else:
			even.append(i)
	ans = []
	i = 0
	j = 0
	while i < len(odd) and j < len(even):
		if odd[i] < even[j]:
			ans.append(odd[i])
			i += 1
		else:
			ans.append(even[j])
			j += 1
	while i < len(odd):
		ans.append(odd[i])
		i += 1
	while j < len(even):
		ans.append(even[j])
		j += 1
	for i in ans:
		print(i, end='')
	print()


for _ in range(int(input())):
	word = list(map(str, input()))
	(even, odd) = ([], [])
	for i in word:
		if int(i) % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	ans = []
	(l, r) = (0, 0)
	while l < len(even) and r < len(odd):
		if even[l] < odd[r]:
			ans.append(even[l])
			l += 1
		else:
			ans.append(odd[r])
			r += 1
	ans += even[l:]
	ans += odd[r:]
	print(''.join(ans))


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	S = list(map(ord, readline().strip()))
	SE = []
	SO = []
	for s in S:
		if s % 2 == 0:
			SE.append(s)
		else:
			SO.append(s)
	LE = len(SE)
	LO = len(SO)
	inf = 10000
	SE.append(inf)
	SO.append(inf)
	cnte = 0
	cnto = 0
	ans = []
	for _ in range(LE + LO):
		if SE[cnte] < SO[cnto]:
			ans.append(SE[cnte])
			cnte += 1
		else:
			ans.append(SO[cnto])
			cnto += 1
	Ans[qu] = ans
for a in Ans:
	sys.stdout.write(''.join(map(chr, a)))
	sys.stdout.write('\n')


t = int(input())
for i in range(t):
	a = input()
	odds = [c for c in a if int(c) % 2]
	evens = [c for c in a if not int(c) % 2]
	o = 0
	e = 0
	output = []
	while o != len(odds) and e != len(evens):
		if odds[o] < evens[e]:
			output += odds[o]
			o += 1
		else:
			output += evens[e]
			e += 1
	output += evens[e:]
	output += odds[o:]
	print(''.join(output))


t = int(input())
for i in range(0, t):
	s = ''
	d = ''
	x = input()
	for i in x:
		c = int(i)
		if c % 2 == 0:
			s += i
		else:
			d += i
	i = 0
	j = 0
	while i < len(s) and j < len(d):
		if s[i] < d[j]:
			print(s[i], end='')
			i += 1
		else:
			print(d[j], end='')
			j += 1
	if i == len(s):
		while j < len(d):
			print(d[j], end='')
			j += 1
	else:
		while i < len(s):
			print(s[i], end='')
			i += 1
	print()


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		N = input().rstrip('\n')
		odd = []
		even = []
		for n_ in N:
			n = int(n_)
			if n % 2:
				odd.append(n)
			else:
				even.append(n)
		odd.reverse()
		even.reverse()
		ans = []
		while True:
			if len(odd) == 0:
				even.reverse()
				ans.extend(even)
				break
			elif len(even) == 0:
				odd.reverse()
				ans.extend(odd)
				break
			elif odd[-1] < even[-1]:
				ans.append(odd.pop())
			else:
				ans.append(even.pop())
		print(''.join(map(str, ans)))
main()


for i in range(int(input())):
	s = input()
	even = []
	odd = []
	for j in s:
		t = int(j)
		if t % 2 == 0:
			even.append(t)
		else:
			odd.append(t)
	a = 0
	b = 0
	s1 = ''
	while a < len(even) and b < len(odd):
		if even[a] < odd[b]:
			s1 += str(even[a])
			a += 1
		else:
			s1 += str(odd[b])
			b += 1
	if a == len(even):
		for j in range(b, len(odd)):
			s1 += str(odd[j])
	else:
		for j in range(a, len(even)):
			s1 += str(even[j])
	print(s1)


t = int(input().strip())
for i in range(t):
	s = input().strip()
	odd = [int(c) for c in s if int(c) % 2 != 0]
	even = [int(c) for c in s if int(c) % 2 == 0]
	(i, j) = (0, 0)
	out = ''
	while i < len(odd) or j < len(even):
		if i == len(odd):
			out += str(even[j])
			j += 1
		elif j == len(even):
			out += str(odd[i])
			i += 1
		elif odd[i] > even[j]:
			out += str(even[j])
			j += 1
		else:
			out += str(odd[i])
			i += 1
	print(out)


n = int(input())
while n:
	n -= 1
	s = input()
	oddq = []
	evenq = []
	sf = []
	i = 0
	while i < len(s):
		if not int(s[i]) % 2:
			evenq.append(s[i])
		else:
			oddq.append(s[i])
		i += 1
	i = 0
	j = 0
	while i < len(oddq) and j < len(evenq):
		if oddq[i] < evenq[j]:
			sf.append(oddq[i])
			i += 1
		else:
			sf.append(evenq[j])
			j += 1
	sf += oddq[i:] + evenq[j:]
	print(''.join(sf))


for _ in range(int(input())):
	s = input()
	(a, b) = ('', '')
	for (i, c) in enumerate(s):
		if int(c) % 2 == 0:
			a += c
		else:
			b += c
	(ia, ib) = (0, 0)
	ans = ''
	while ia < len(a) and ib < len(b):
		if a[ia] < b[ib]:
			ans += a[ia]
			ia += 1
		else:
			ans += b[ib]
			ib += 1
	while ia < len(a):
		ans += a[ia]
		ia += 1
	while ib < len(b):
		ans += b[ib]
		ib += 1
	print(ans)


for t in range(int(input())):
	str = input()
	even = []
	odd = []
	for i in str:
		if int(i) % 2 == 0:
			even.append(int(i))
		else:
			odd.append(int(i))
	even.append(100)
	odd.append(100)
	i = 0
	j = 0
	stack = []
	while even[i] != odd[j]:
		if even[i] < odd[j]:
			stack.append(even[i])
			i += 1
		else:
			stack.append(odd[j])
			j += 1
	for i in stack:
		print(i, end='')
	print()


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	a = gbs()
	(o, e) = ([], [])
	ans = []
	for i in reversed(range(len(a))):
		(o if a[i] & 1 else e).append((a[i], i))
	while o and e:
		(l, r) = (min(o, e, key=lambda x: x[-1][1]), max(o, e, key=lambda x: x[-1][1]))
		if l[-1][0] < r[-1][0]:
			ans.append(l.pop()[0])
		else:
			while r and l[-1][0] > r[-1][0]:
				ans.append(r.pop()[0])
	o = max(o, e, key=len)
	while o:
		ans.append(o.pop()[0])
	for v in ans:
		print(v, end='')
	print()


for _ in range(int(input())):
	a = list(input())
	odd = []
	even = []
	for elem in a:
		elem = int(elem)
		if elem % 2 == 0:
			even.append(elem)
		else:
			odd.append(elem)
	i = 0
	j = 0
	output = []
	for _ in range(len(a)):
		if i == len(odd):
			output.append(str(even[j]))
			j += 1
		elif j == len(even):
			output.append(str(odd[i]))
			i += 1
		elif odd[i] < even[j]:
			output.append(str(odd[i]))
			i += 1
		else:
			output.append(str(even[j]))
			j += 1
	print(''.join(output))


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(100000000)
import os
import sys
from sys import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
z = lambda : sys.stdin.readline().rstrip('\r\n')

def op():
	return list(map(int, z().split()))

def o():
	return int(z())

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
for _ in range(o()):
	s = z()
	odd = []
	even = []
	for i in s:
		if int(i) & 1:
			odd.append(int(i))
		else:
			even.append(int(i))
	odd.reverse()
	even.reverse()
	ans = []
	while odd and even:
		if odd[-1] < even[-1]:
			ans.append(odd.pop())
		else:
			ans.append(even.pop())
	ans += reversed(odd)
	ans += reversed(even)
	out = []
	out.append(''.join((str(x) for x in ans)))
	print(out[0])


import os
import sys
from io import BytesIO, IOBase
from math import gcd, inf, sqrt

def lcm(a, b):
	return a * b // gcd(a, b)

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def printDivisors(n):
	i = 2
	z = []
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def cheaker(a):
	j = 1
	p = False
	for i in a:
		if i != j:
			break
		j += 1
	q = len(a)
	for i in a[::-1]:
		if i != q:
			break
		q -= 1
	for i in range(j - 1, q):
		if a[i] == i + 1:
			return False
	return True

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	x = []
	for i in range(2, n + 1):
		if prime[i]:
			x.append(i)
	return x

def main():
	for ii in range(int(input())):
		odd = []
		even = []
		s = input().strip()
		x = 1
		for j in range(1, len(s)):
			if s[j] != s[j - 1]:
				if int(s[j - 1]) % 2 == 1:
					odd.append([s[j - 1], x])
					x = 0
				else:
					even.append([s[j - 1], x])
					x = 0
			x += 1
		if int(s[-1]) % 2:
			odd.append([s[-1], x])
		else:
			even.append([s[-1], x])
		(i, j) = (0, 0)
		an = []
		while j < len(even) and i < len(odd):
			if int(odd[i][0]) < int(even[j][0]):
				an.append(odd[i][0] * odd[i][1])
				i += 1
			elif int(odd[i][0]) > int(even[j][0]):
				an.append(even[j][0] * even[j][1])
				j += 1
		while i < len(odd):
			an.append(odd[i][0] * odd[i][1])
			i += 1
		while j < len(even):
			an.append(even[j][0] * even[j][1])
			j += 1
		print(''.join(an))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def minimize(x):
	x = [int(i) for i in x]
	numbers = [[], []]
	for i in x:
		if multiplisity(i):
			numbers[0].append(i)
		else:
			numbers[1].append(i)
	result = []
	count1 = 0
	count2 = 0
	while count1 != len(numbers[0]) and count2 != len(numbers[1]):
		if numbers[0][count1] < numbers[1][count2]:
			result.append(numbers[0][count1])
			count1 += 1
		else:
			result.append(numbers[1][count2])
			count2 += 1
	if count1 == len(numbers[0]):
		result += numbers[1][count2:]
	else:
		result += numbers[0][count1:]
	return ''.join([str(i) for i in result])

def multiplisity(a):
	if a % 2 == 0:
		return True
	return False
for i in range(int(input().strip())):
	x = input().strip()
	print(minimize(x))


def li():
	return [int(i) for i in input()]
for _ in range(int(input())):
	l = li()
	a = []
	b = []
	for i in l:
		if i & 1:
			a.append(i)
		else:
			b.append(i)
	ans = []
	i = j = 0
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			j += 1
	ans += a[i:]
	ans += b[j:]
	print(''.join((str(k) for k in ans)))


def minimize(number):
	(odd, even) = ([], [])
	for i in number:
		if i % 2 == 1:
			odd.append(i)
		else:
			even.append(i)
	odd.reverse()
	even.reverse()
	ans = []
	while odd and even:
		if odd[-1] < even[-1]:
			ans.append(odd.pop())
		else:
			ans.append(even.pop())
	if odd:
		ans.extend(reversed(odd))
	else:
		ans.extend(reversed(even))
	return ''.join([str(i) for i in ans])
q = int(input())
for _ in range(q):
	number = map(int, list(input()))
	print(minimize(number))


for t in range(int(input())):
	st = input()
	li = list(map(int, st))
	n = len(li)
	odd = []
	even = []
	i = 0
	while i < n:
		if li[i] % 2 == 0:
			even.append(li[i])
		else:
			odd.append(li[i])
		i = i + 1
	od = 0
	ev = 0
	while od < len(odd) and ev < len(even):
		if odd[od] < even[ev]:
			print(odd[od], end='')
			od += 1
		else:
			print(even[ev], end='')
			ev += 1
	while od < len(odd):
		print(odd[od], end='')
		od += 1
	while ev < len(even):
		print(even[ev], end='')
		ev += 1
	print()


n = int(input())
for ewfe in range(n):
	s = input()
	par = []
	npar = []
	for i in s:
		if int(i) % 2 == 0:
			par.append(int(i))
		else:
			npar.append(int(i))
	pa = 0
	npa = 0
	odp = []
	while True:
		if pa == len(par) and npa == len(npar):
			break
		if pa <= len(par) - 1 and npa <= len(npar) - 1:
			if par[pa] < npar[npa]:
				odp.append(par[pa])
				pa += 1
			else:
				odp.append(npar[npa])
				npa += 1
		elif pa == len(par):
			odp.append(npar[npa])
			npa += 1
		else:
			odp.append(par[pa])
			pa += 1
	k = len(odp)
	for i in range(k):
		if i < k - 1:
			print(odp[i], end='')
		else:
			print(odp[i])


from collections import deque
t = int(input())
for _ in range(t):
	s = list(map(int, input().strip()))
	n = len(s)
	odds = deque([i for i in s if i % 2])
	evens = deque([i for i in s if not i % 2])
	ans = []
	while odds and evens:
		if odds[0] < evens[0]:
			ans.append(odds[0])
			odds.popleft()
		else:
			ans.append(evens[0])
			evens.popleft()
	ans += odds + evens
	print(''.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	w = input()
	a = []
	b = []
	for i in range(len(w)):
		if int(w[i]) % 2 == 0:
			a.append(int(w[i]))
		else:
			b.append(int(w[i]))
	t = 0
	p = 0
	ans = []
	u = 0
	f = 0
	c = len(w)
	for i in range(c):
		if p == len(b):
			ans += a[t:]
			break
		if t == len(a):
			ans += b[p:]
			break
		if f == 0 and a[t] < b[p]:
			ans.append(a[t])
			t += 1
		elif u == 0:
			ans.append(b[p])
			p += 1
	print(*ans, sep='')


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
for xyz in range(0, int(input())):
	s = input()
	o = []
	e = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(i)
		else:
			o.append(i)
	o.append(10)
	e.append(10)
	i = 0
	j = 0
	while e[i] != 10 or o[j] != 10:
		if int(e[i]) < int(o[j]):
			print(e[i], end='')
			i += 1
		else:
			print(o[j], end='')
			j += 1
	print('')


for _ in range(int(input())):
	string = input()
	even = []
	length = len(string)
	odd = []
	for i in string:
		if int(i) % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	output = ''
	i = 0
	j = 0
	l1 = len(even)
	l2 = len(odd)
	while i < l1 and j < l2:
		if even[i] < odd[j]:
			output += str(even[i])
			i += 1
		else:
			output += str(odd[j])
			j += 1
	if i == l1:
		output = output + ''.join(odd[j:])
	else:
		output = output + ''.join(even[i:])
	print(output)


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	(e, o, a) = ([], [], [])
	for c in I():
		x = ord(c) - ord('0')
		if x & 1:
			o.append(x)
		else:
			e.append(x)
	(i, j) = (0, 0)
	while i < len(o) or j < len(e):
		if i < len(o) and j < len(e):
			if o[i] < e[j]:
				a.append(chr(o[i] + ord('0')))
				i += 1
			else:
				a.append(chr(e[j] + ord('0')))
				j += 1
		elif i < len(o):
			a.append(chr(o[i] + ord('0')))
			i += 1
		else:
			a.append(chr(e[j] + ord('0')))
			j += 1
	print(''.join(a))


k = int(input())
r = []
for _ in ' ' * k:
	(*s,) = list(input())
	e = []
	o = []
	t = ''
	for i in s:
		if int(i) % 2 == 0:
			e += [i]
		else:
			o += [i]
	i = 0
	j = 0
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			print(e[i], end='')
			i += 1
		else:
			print(o[j], end='')
			j += 1
	while i < len(e):
		print(e[i], end='')
		i += 1
	while j < len(o):
		print(o[j], end='')
		j += 1
	print('')


import array
import math
import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		S = inp()
		print(solve(S))

def solve(S):
	ev = []
	od = []
	for c in S:
		if c in ('0', '2', '4', '6', '8'):
			ev.append(c)
		else:
			od.append(c)
	ans = []
	i = 0
	iz = len(ev)
	j = 0
	jz = len(od)
	while i < iz or j < jz:
		if i == iz:
			while j < jz:
				ans.append(od[j])
				j += 1
			continue
		if j == jz:
			while i < iz:
				ans.append(ev[i])
				i += 1
			continue
		ic = ev[i]
		jc = od[j]
		if ic < jc:
			ans.append(ic)
			i += 1
		else:
			ans.append(jc)
			j += 1
	return ''.join(ans)
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


import sys, os, io
for _ in range(int(input())):
	s = list(input())
	s = [int(i) for i in s]
	n = len(s)
	o = -1
	e = -1
	for i in range(len(s)):
		if s[i] % 2 == 1 and o == -1:
			o = i
		elif s[i] % 2 == 0 and e == -1:
			e = i
		if o != -1 and e != -1:
			break
	curr = 0
	ans = []
	if o == -1 or e == -1:
		ans = s[:]
	else:
		while o < n and e < n:
			if s[o] <= s[e]:
				ans.append(s[o])
				o += 1
				while o < n:
					if s[o] % 2 == 0:
						o += 1
					else:
						break
			else:
				ans.append(s[e])
				e += 1
				while e < n:
					if s[e] % 2 == 1:
						e += 1
					else:
						break
		if o < n:
			for i in range(o, n):
				if s[i] % 2 == 1:
					ans.append(s[i])
		else:
			for i in range(e, n):
				if s[i] % 2 == 0:
					ans.append(s[i])
	for i in ans:
		print(i, end='')
	print()


for _ in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		x = int(i)
		if x % 2 == 0:
			e.append(x)
		else:
			o.append(x)
	e = e[::-1]
	o = o[::-1]
	z = []
	while len(o) > 0 and len(e) > 0:
		if e[-1] < o[-1]:
			g = e.pop()
		else:
			g = o.pop()
		z.append(str(g))
	while len(o) > 0:
		g = o.pop()
		z.append(str(g))
	while len(e) > 0:
		g = e.pop()
		z.append(str(g))
	r = ''.join(z)
	print(r)


t = int(input())
for _ in range(t):
	s = input()
	ans = ''
	e = []
	o = []
	for d in s:
		if ord(d) % 2 == 0:
			e.append(d)
		else:
			o.append(d)
	e.append('ё')
	o.append('ё')
	i = 0
	j = 0
	while e[i] != 'ё' or o[j] != 'ё':
		if ord(e[i]) < ord(o[j]):
			ans += e[i]
			i += 1
		else:
			ans += o[j]
			j += 1
	print(ans)


import sys
INF = 10 ** 9
sys.setrecursionlimit(10 ** 8)
n = int(input())
for i in range(n):
	s = input().rstrip()
	odds = []
	evens = []
	for ch in s:
		if int(ch) % 2 == 0:
			evens.append(int(ch))
		else:
			odds.append(int(ch))
	evens.append(INF)
	odds.append(INF)
	ans = []
	eid = 0
	oid = 0
	while evens[eid] != INF or odds[oid] != INF:
		if evens[eid] < odds[oid]:
			ans.append(evens[eid])
			eid += 1
		else:
			ans.append(odds[oid])
			oid += 1
	print(''.join([str(item) for item in ans]))


from math import *
from bisect import *
from collections import Counter, defaultdict
I = lambda : int(input())
SI = lambda : input()
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	s = SI()
	e = []
	o = []
	for i in s:
		if int(i) % 2:
			o.append(int(i))
		else:
			e.append(int(i))
	o.reverse()
	e.reverse()
	ans = []
	while e and o:
		if e[-1] < o[-1]:
			ans.append(e.pop())
		else:
			ans.append(o.pop())
	if e:
		while e:
			ans.append(e.pop())
	else:
		while o:
			ans.append(o.pop())
	print(''.join(map(str, ans)))


t = int(input())
for _ in range(t):
	n = list(input())
	odd = []
	even = []
	for i in range(len(n)):
		if int(n[i]) % 2 == 0:
			even.append(int(n[i]))
		else:
			odd.append(int(n[i]))
	(i, j) = (0, 0)
	no = []
	while i <= len(even) - 1 and j <= len(odd) - 1:
		if even[i] < odd[j]:
			no.append(even[i])
			i += 1
		else:
			no.append(odd[j])
			j += 1
	if i == len(even):
		for h in range(j, len(odd)):
			no.append(odd[h])
	else:
		for h in range(i, len(even)):
			no.append(even[h])
	for k in no:
		print(k, end='')
	print()


for _ in range(int(input())):
	s = input()
	o = []
	e = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(i)
		else:
			o.append(i)
	ans = []
	x = 0
	y = 0
	while len(e) > x and len(o) > y:
		if int(o[y]) > int(e[x]):
			ans.append(e[x])
			x += 1
		else:
			ans.append(o[y])
			y += 1
	print(''.join(ans + o[y:] + e[x:]))


t = int(input())
resAr = []
for z in range(t):
	nums = [int(i) for i in input()]
	eNums = []
	oNums = []
	(eC, oC) = (0, 0)
	for i in nums:
		if i % 2 == 0:
			eNums.append(i)
			eC += 1
		else:
			oNums.append(i)
			oC += 1
	(i, j) = (0, 0)
	rS = []
	while i < eC and j < oC:
		if eNums[i] < oNums[j]:
			rS.append(str(eNums[i]))
			i += 1
		else:
			rS.append(str(oNums[j]))
			j += 1
	while i < eC:
		rS.append(str(eNums[i]))
		i += 1
	while j < oC:
		rS.append(str(oNums[j]))
		j += 1
	resAr.append(rS)
for i in resAr:
	print(''.join(i))


t = int(input())
for p in range(t):
	n = input()
	even = []
	odd = []
	for d in n:
		if int(d) % 2 == 0:
			even.append(d)
		else:
			odd.append(d)
	i = 0
	j = 0
	ans = []
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			ans.append(even[i])
			i += 1
		else:
			ans.append(odd[j])
			j += 1
	if i < len(even):
		while i != len(even):
			ans.append(even[i])
			i += 1
	elif j < len(odd):
		while j != len(odd):
			ans.append(odd[j])
			j += 1
	print(''.join(ans))


import sys
even_digits = frozenset((str(n) for n in range(0, 9, 2)))
odd_digits = frozenset((str(n) for n in range(1, 10, 2)))
num_inputs = int(input())
for _ in range(num_inputs):
	n = input()
	evens = tuple((s for s in n if s in even_digits))
	odds = tuple((s for s in n if s in odd_digits))
	evens_len = len(evens)
	odds_len = len(odds)
	result = ''
	even_index = 0
	odd_index = 0
	while True:
		if even_index == evens_len:
			sys.stdout.write(''.join(odds[odd_index:]) + '\n')
			break
		elif odd_index == odds_len:
			sys.stdout.write(''.join(evens[even_index:]) + '\n')
			break
		if evens[even_index] < odds[odd_index]:
			sys.stdout.write(evens[even_index])
			even_index += 1
		else:
			sys.stdout.write(odds[odd_index])
			odd_index += 1
sys.stdout.flush()


from heapq import merge
for i in range(0, int(input())):
	digit = list(map(ord, input()))
	print(''.join(map(chr, merge(*[[i for i in digit if i & 1 == 0], [i for i in digit if i & 1 == 1]]))))


for _ in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(i)
		else:
			o.append(i)
	l1 = l2 = 0
	ans = []
	while l1 < len(e) and l2 < len(o):
		if int(e[l1]) < int(o[l2]):
			ans.append(e[l1])
			l1 += 1
		else:
			ans.append(o[l2])
			l2 += 1
	ans += e[l1:] + o[l2:]
	print(''.join(ans))


l = []
for _ in range(int(input())):
	n = list(map(int, list(input())))
	odd = []
	even = []
	for i in n:
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	odd.reverse()
	even.reverse()
	while len(odd) > 0 and len(even) > 0:
		if odd[-1] < even[-1]:
			print(odd[-1], end='')
			odd.pop()
		else:
			print(even[-1], end='')
			even.pop()
	if len(odd) > 0:
		odd.reverse()
		print(''.join(list(map(str, odd))))
	if len(even) > 0:
		even.reverse()
		print(''.join(list(map(str, even))))


t = int(input().rstrip())
for case in range(t):
	ss = input().rstrip()
	s = ss
	(odd_lis, even_lis) = ([], [])
	for i in range(len(ss)):
		if ord(ss[i]) % 2:
			odd_lis.append(int(ss[i]))
		else:
			even_lis.append(int(ss[i]))
	ans = []
	lim = len(odd_lis)
	lim_even = len(even_lis)
	(odd_idx, even_idx) = (0, 0)
	if lim == lim + lim_even:
		print(ss)
		continue
	if lim_even == lim + lim_even:
		print(ss)
		continue
	while odd_idx < lim:
		if odd_lis[odd_idx] > even_lis[even_idx]:
			ans.append(even_lis[even_idx])
			even_idx += 1
			if even_idx == lim_even:
				while odd_idx < lim:
					ans.append(odd_lis[odd_idx])
					odd_idx += 1
		else:
			ans.append(odd_lis[odd_idx])
			odd_idx += 1
	for i in range(even_idx, lim_even):
		ans.append(even_lis[i])
	for i in ans:
		print(i, end='')
	print()


t = int(input())
for i in range(t):
	numbers = [int(j) for j in list(input())]
	even = []
	odd = []
	for j in numbers:
		if j % 2 == 0:
			even.append(j)
		else:
			odd.append(j)
	even.reverse()
	odd.reverse()
	ans = []
	while even and odd:
		if even[len(even) - 1] < odd[len(odd) - 1]:
			ans.append(even.pop())
		else:
			ans.append(odd.pop())
	if even:
		ans.extend(reversed(even))
	elif odd:
		ans.extend(reversed(odd))
	print(''.join([str(j) for j in ans]))


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
(t,) = I()
while t:
	t -= 1
	s = input()
	n = len(s)
	a = [0] * (n + 10)
	b = [0] * (n + 10)
	(odd, even) = ([], [])
	for i in range(n):
		k = int(s[i])
		if k % 2:
			odd.append(s[i])
		else:
			even.append(s[i])
	i = 0
	j = 0
	ans = []
	while i < len(odd) and j < len(even):
		if even[j] < odd[i]:
			ans.append(even[j])
			j += 1
		else:
			ans.append(odd[i])
			i += 1
	ans = ''.join(ans) + ''.join(odd[i:]) + ''.join(even[j:])
	print(ans)


t = int(input())
for _ in range(t):
	number = list(input())
	odd = []
	even = []
	for num in number:
		if int(num) % 2:
			odd.append(int(num))
		else:
			even.append(int(num))
	(ind1, ind2) = (0, 0)
	while True:
		if ind1 >= len(odd):
			break
		if ind2 >= len(even):
			break
		if odd[ind1] < even[ind2]:
			print(odd[ind1], end='')
			ind1 += 1
		else:
			print(even[ind2], end='')
			ind2 += 1
	while ind1 < len(odd):
		print(odd[ind1], end='')
		ind1 += 1
	while ind2 < len(even):
		print(even[ind2], end='')
		ind2 += 1
	print()


import heapq
t = int(input())
for _ in range(t):
	n = input()
	l = [[], []]
	for j in n:
		if int(j) % 2 == 1:
			l[0].append(int(j))
		else:
			l[1].append(int(j))
	merged = heapq.merge(l[0], l[1])
	for i in merged:
		print(i, end='')
	print()


from heapq import merge
for _ in range(int(input())):
	a = input()
	e = []
	o = []
	for i in a:
		e.append(int(i)) if int(i) % 2 == 0 else o.append(int(i))
	print(*list(merge(e, o)), sep='')


t = int(input())
for i in range(t):
	chet = []
	nechet = []
	res = []
	a = input()
	a = list(a)
	for j in a:
		j = int(j)
		if j % 2 == 0:
			chet.append(j)
		else:
			nechet.append(j)
	chet_pos = 0
	nechet_pos = 0
	while chet_pos < len(chet) and nechet_pos < len(nechet):
		if chet[chet_pos] < nechet[nechet_pos]:
			res.append(str(chet[chet_pos]))
			chet_pos += 1
		else:
			res.append(str(nechet[nechet_pos]))
			nechet_pos += 1
	for j in range(chet_pos, len(chet)):
		res.append(str(chet[j]))
	for j in range(nechet_pos, len(nechet)):
		res.append(str(nechet[j]))
	print(''.join(res))


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	a = list(map(int, list(input())))
	evens = []
	odds = []
	for val in a:
		if val & 1:
			odds.append(val)
		else:
			evens.append(val)
	ans = []
	n = len(evens)
	m = len(odds)
	i = 0
	j = 0
	while i < n and j < m:
		if evens[i] < odds[j]:
			ans.append(evens[i])
			i += 1
		else:
			ans.append(odds[j])
			j += 1
	if i == n:
		ans.extend(odds[j:])
	else:
		ans.extend(evens[i:])
	print(''.join(map(str, ans)))


import sys
import math
import bisect
from collections import deque
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}'.format(i) + sep)
INF = float('inf')
MOD = int(1000000000.0 + 7)
for _ in range(int(input())):
	s = input()
	ans = []
	dq = deque()
	dq.append([int(s[0]), 1])
	for i in s[1:]:
		i = int(i)
		if dq[-1][0] % 2 == i % 2:
			if dq[-1][0] == i:
				dq[-1][1] += 1
			else:
				dq.append([i, 1])
		else:
			j = 0
			while j < len(dq) and i > dq[j][0]:
				j += 1
			for k in range(j):
				ans.append(dq.popleft())
			if dq:
				ans.append([i, 1])
			else:
				dq.append([i, 1])
	for (i, j) in ans:
		print(str(i) * j, end='')
	for (i, j) in dq:
		print(str(i) * j, end='')
	print()


for x in range(int(input())):
	l = list(map(int, input()))
	a = []
	b = []
	for i in range(len(l)):
		if l[i] % 2:
			a.append(l[i])
		else:
			b.append(l[i])
	a.append(10)
	b.append(10)
	i = j = 0
	k = ''
	while i + j < len(l):
		if a[i] < b[j]:
			k += str(a[i])
			i += 1
		else:
			k += str(b[j])
			j += 1
	print(k)


t = int(input())
for i2 in range(t):
	ans = []
	s = str(input())
	(even, odd) = ([], [])
	for i in range(len(s)):
		if int(s[i]) % 2 == 0:
			even.append(int(s[i]))
		else:
			odd.append(int(s[i]))
	pointer = 0
	for i in range(len(even)):
		while pointer < len(odd) and odd[pointer] < even[i]:
			ans.append(odd[pointer])
			pointer += 1
		ans.append(even[i])
	for i in range(pointer, len(odd)):
		ans.append(odd[i])
	for i in ans:
		print(i, end='')
	print('')


from sys import stdin, stdout
from math import gcd, sqrt, factorial
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	e = []
	o = []
	ln = 0
	for i in map(int, S()):
		if i & 1:
			o += (i,)
		else:
			e += (i,)
		ln += 1
	ans = []
	e.reverse()
	o.reverse()
	for i in range(ln):
		if not e:
			ans = ans + o[::-1]
			break
		elif not o:
			ans = ans + e[::-1]
			break
		if e[-1] < o[-1]:
			ans += (e.pop(),)
		else:
			ans += (o.pop(),)
	print(*ans, sep='')


import sys
input = sys.stdin.readline
t = int(input())
ESET = {'0', '2', '4', '6', '8'}
from collections import deque
for test in range(t):
	n = input().strip()
	E = deque()
	O = deque()
	for s in n:
		if s in ESET:
			E.append(s)
		else:
			O.append(s)
	ans = []
	while E and O:
		if E[0] < O[0]:
			ele = E.popleft()
			ans.append(ele)
		else:
			ele = O.popleft()
			ans.append(ele)
	if len(E):
		ans.extend(E)
	elif len(O):
		ans.extend(O)
	print(''.join(ans))


from heapq import merge
T = int(input())
x = []
y = []
while T != 0:
	T -= 1
	s = str(input())
	for i in range(len(s)):
		t = int(s[i])
		if t % 2 == 0:
			x.append(t)
		else:
			y.append(t)
	j = merge(x, y)
	for k in j:
		print(k, end='')
	print()
	x.clear()
	y.clear()


def process_one(n_str):
	list_of_digits = [int(d) for d in n_str]
	odds = [x for x in list_of_digits if x % 2 == 1]
	evens = [x for x in list_of_digits if x % 2 == 0]
	(i, j) = (0, 0)
	(new_i, new_j) = (0, 0)
	result = []
	while True:
		if i < len(odds) and j < len(evens):
			if odds[i] < evens[j]:
				result.append(odds[i])
				new_i = i + 1
			if odds[i] > evens[j]:
				result.append(evens[j])
				new_j = j + 1
		elif i < len(odds):
			result.append(odds[i])
			new_i = i + 1
		elif j < len(evens):
			result.append(evens[j])
			new_j = j + 1
		else:
			break
		i = new_i
		j = new_j
	print(''.join((str(i) for i in result)))
t = int(input())
ns = []
for _ in range(t):
	ns.append(input())
for x in ns:
	process_one(x)


for _ in range(int(input())):
	a = list(input())
	n = len(a)
	odd = []
	even = []
	for i in range(n):
		a[i] = int(a[i])
		if a[i] % 2 == 0:
			odd.append(a[i])
		else:
			even.append(a[i])
	lo = len(odd)
	le = len(even)
	oi = 0
	ei = 0
	while oi < lo and ei < le:
		if odd[oi] < even[ei]:
			print(odd[oi], end='')
			oi += 1
		else:
			print(even[ei], end='')
			ei += 1
	for i in range(oi, lo):
		print(odd[i], end='')
	for i in range(ei, le):
		print(even[i], end='')
	print()


def get_min(num_s):
	num_s = list(map(int, list(num_s)))
	os = list(filter(lambda x: x % 2, num_s))
	es = list(filter(lambda x: not x % 2, num_s))
	osz = len(os)
	esz = len(es)
	o_idx = 0
	e_idx = 0
	fl = []
	while o_idx < osz and e_idx < esz:
		e = es[e_idx]
		o = os[o_idx]
		if e < o:
			fl.append(e)
			e_idx += 1
		else:
			fl.append(o)
			o_idx += 1
	fl.extend(os[o_idx:])
	fl.extend(es[e_idx:])
	return ''.join(map(str, fl))
for _ in range(int(input())):
	print(get_min(input()))


for _ in range(int(input())):
	s = list(map(int, list(input())))
	odds = []
	evens = []
	for i in s:
		if i % 2 == 0:
			evens.append(i)
		else:
			odds.append(i)
	i = 0
	j = 0
	while i < len(odds) and j < len(evens):
		if odds[i] < evens[j]:
			print(odds[i], end='')
			i += 1
		else:
			print(evens[j], end='')
			j += 1
	while i < len(odds):
		print(odds[i], end='')
		i += 1
	while j < len(evens):
		print(evens[j], end='')
		j += 1
	print()


def run_testcase():
	digits = [int(x) for x in input()]
	odds = list(filter(lambda x: x % 2 == 1, digits))
	evens = list(filter(lambda x: x % 2 == 0, digits))
	smallest = []
	i = 0
	j = 0
	while i < len(odds) and j < len(evens):
		if odds[i] < evens[j]:
			smallest.append(odds[i])
			i += 1
		else:
			smallest.append(evens[j])
			j += 1
	smallest += odds[i:]
	smallest += evens[j:]
	return ''.join((str(x) for x in smallest))
testcase_count = int(input())
for i in range(testcase_count):
	print(str(run_testcase()))


from sys import stdout, stdin
for i in stdin:
	q = int(i)
	break
for i in stdin:
	i = list(map(int, i.strip()))
	A = []
	E = [j for j in i if j % 2 == 0]
	O = [j for j in i if j % 2 == 1]
	(a, b) = (0, 0)
	while a + b != len(i):
		if a == len(E):
			A.append(O[b])
			b += 1
		elif b == len(O):
			A.append(E[a])
			a += 1
		elif E[a] < O[b]:
			A.append(E[a])
			a += 1
		else:
			A.append(O[b])
			b += 1
	A = list(map(str, A))
	stdout.write(''.join(A) + '\n')
	q -= 1
	if not q:
		break


for itr in range(int(input())):
	a = list(map(int, list(input())))
	even = []
	odd = []
	for i in range(len(a)):
		if a[i] % 2:
			odd.append(a[i])
		else:
			even.append(a[i])
	ans = []
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			ans.append(even[i])
			i += 1
		else:
			ans.append(odd[j])
			j += 1
	while i < len(even):
		ans.append(even[i])
		i += 1
	while j < len(odd):
		ans.append(odd[j])
		j += 1
	for i in ans:
		print(i, end='')
	print()


def count(s):
	zero = 0
	one = 0
	for i in range(len(s)):
		if s[i] == '0':
			zero += 1
		else:
			one += 1
	return (zero, one)
for t in range(int(input())):
	n = input()
	even = []
	odd = []
	for i in range(len(n)):
		if int(n[i]) & 1:
			odd.append(int(n[i]))
		else:
			even.append(int(n[i]))
	i = 0
	j = 0
	while i < len(odd) and j < len(even):
		if even[j] < odd[i]:
			print(even[j], end='')
			j += 1
		else:
			print(odd[i], end='')
			i += 1
	while i < len(odd):
		print(odd[i], end='')
		i += 1
	while j < len(even):
		print(even[j], end='')
		j += 1
	print()


for _ in range(int(input())):
	s = list(map(int, list(input())))
	even = []
	odd = []
	for i in s:
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			i += 1
			print(even[i - 1], end='')
		else:
			j += 1
			print(odd[j - 1], end='')
	while i < len(even):
		i += 1
		print(even[i - 1], end='')
	while j < len(odd):
		j += 1
		print(odd[j - 1], end='')
	print('')


from collections import *
from math import *
t = int(input())
for y in range(t):
	s = list(input())
	n = len(s)
	a = []
	b = []
	for i in s:
		if int(i) % 2 == 0:
			a.append(i)
		else:
			b.append(i)
	j = 0
	k = 0
	n1 = len(a)
	n2 = len(b)
	for i in range(n):
		if j == n1:
			s[i] = b[k]
			k += 1
		elif k == n2:
			s[i] = a[j]
			j += 1
		elif a[j] < b[k]:
			s[i] = a[j]
			j += 1
		else:
			s[i] = b[k]
			k += 1
	print(''.join(s))


for a in [input() for i in range(int(input()))]:
	(a1, a2) = ([], [])
	for ai in a:
		ai = int(ai)
		if ai % 2:
			a1 += [ai]
		else:
			a2 += [ai]
	(l1, l2) = (len(a1), len(a2))
	if l1 == 0 or l2 == 0:
		print(a)
		continue
	a = []
	(i, j) = (0, 0)
	while i < l1 or j < l2:
		if i >= l1:
			a += a2[j:]
			break
		elif j >= l2:
			a += a1[i:]
			break
		elif a1[i] > a2[j]:
			a += [a2[j]]
			j += 1
		else:
			a += [a1[i]]
			i += 1
	print(''.join(map(str, a)))


from collections import deque
from sys import stdin, stdout
input = stdin.readline

def getAns(li):
	odds = deque()
	evens = deque()
	for i in li:
		if i % 2 == 0:
			evens.append(i)
		else:
			odds.append(i)
	evens.append(10)
	odds.append(10)
	ans = [0] * len(li)
	i = 0
	while i < len(li):
		if evens[0] < odds[0]:
			ans[i] = evens.popleft()
		else:
			ans[i] = odds.popleft()
		i += 1
	for i in ans:
		stdout.write(str(i))
for _ in range(int(input())):
	getAns(list(map(int, input().rstrip())))
	stdout.write('\n')


a = int(input())
for i in range(a):
	s = input()
	ans = []
	gan = []
	for i in range(len(s)):
		if int(s[i]) % 2 == 1:
			ans.append(int(s[i]))
		else:
			gan.append(int(s[i]))
	fin = []
	l1 = 0
	l2 = 0
	while l1 < len(ans) and l2 < len(gan):
		if ans[l1] < gan[l2]:
			fin.append(ans[l1])
			l1 += 1
		else:
			fin.append(gan[l2])
			l2 += 1
	for i in range(l1, len(ans)):
		fin.append(ans[i])
	for i in range(l2, len(gan)):
		fin.append(gan[i])
	print(''.join(map(str, fin)))


n = int(input())
for t in range(n):
	a = [int(c) for c in input()]
	cur = 0
	result = []
	for i in range(1, len(a)):
		if a[cur] & 1 == a[i] & 1:
			continue
		while cur < i:
			if a[cur] < a[i]:
				if a[cur] != -1:
					result.append(str(a[cur]))
				cur += 1
			else:
				result.append(str(a[i]))
				a[i] = -1
				break
	for i in range(cur, len(a)):
		if a[i] != -1:
			result.append(str(a[i]))
	print(''.join(result))


from heapq import merge
for _ in range(int(input())):
	o = [[], []]
	for n in input():
		o[int(n) % 2] += n
	print(''.join(merge(*o)))


from heapq import merge
t = int(input())
for _ in range(0, t):
	s = [i for i in input()]
	ee = []
	oo = []
	for i in s:
		if int(i) & 1:
			oo += [i]
		else:
			ee += [i]
	ans = list(merge(ee, oo))
	print(''.join(ans))


for _ in range(int(input())):
	s = input()
	odd = []
	even = []
	for l in s:
		if int(l) % 2 == 0:
			even.append(int(l))
		else:
			odd.append(int(l))
	ans = []
	el = 0
	ol = 0
	while el != len(even) and ol != len(odd):
		a = even[el]
		b = odd[ol]
		if a < b:
			ans.append(a)
			el += 1
		else:
			ans.append(b)
			ol += 1
	if el == len(even):
		ans = ans + odd[ol:]
	else:
		ans = ans + even[el:]
	print(''.join(map(str, ans)))


t = int(input())
for ic in range(t):
	n = list(map(int, list(input().strip())))
	(odds, evens) = ([], [])
	for i in range(len(n) - 1, -1, -1):
		if n[i] & 1:
			odds.append(n[i])
		else:
			evens.append(n[i])
	while odds and evens:
		if odds[-1] < evens[-1]:
			print(odds.pop(), end='')
		else:
			print(evens.pop(), end='')
	while odds:
		print(odds.pop(), end='')
	while evens:
		print(evens.pop(), end='')
	print()


T = int(input())
results = []
for _ in range(T):
	msg = input()
	odds = []
	evens = []
	for c in msg:
		if int(c) % 2 == 0:
			evens.append(c)
		else:
			odds.append(c)
	i = j = 0
	out = []
	while i < len(odds) and j < len(evens):
		if int(odds[i]) < int(evens[j]):
			out.append(odds[i])
			i += 1
		else:
			out.append(evens[j])
			j += 1
	while i < len(odds):
		out.append(odds[i])
		i += 1
	while j < len(evens):
		out.append(evens[j])
		j += 1
	results.append(''.join(out))
for i in results:
	print(i)


t = int(input())
for _ in range(t):
	s = input()
	(odd_seq, oi) = ([0] * len(s), 0)
	(even_seq, ei) = ([0] * len(s), 0)
	for c in s:
		v = int(c)
		if v % 2 == 0:
			even_seq[ei] = v
			ei += 1
		else:
			odd_seq[oi] = v
			oi += 1
	res = ''
	(n, m) = (oi, ei)
	(l, r) = (0, 0)
	while l < n or r < m:
		if l < n and r < m:
			v = odd_seq[l]
			if odd_seq[l] < even_seq[r]:
				l += 1
			else:
				v = even_seq[r]
				r += 1
			res += str(v)
		elif l < n:
			res += str(odd_seq[l])
			l += 1
		else:
			res += str(even_seq[r])
			r += 1
	print(res)


n = int(input())
for _ in range(n):
	num = [int(x) for x in input()]
	l_n = len(num)
	odd = [x for x in num if x & 1 == 1]
	even = [x for x in num if x & 1 == 0]
	(oi, ei, lo, le) = (0, 0, len(odd), len(even))
	for _ in range(l_n):
		if ei == le:
			print(''.join((str(x) for x in odd[oi:])))
			break
		elif oi == lo:
			print(''.join((str(x) for x in even[ei:])))
			break
		elif lo > oi and odd[oi] < even[ei]:
			print(odd[oi], end='')
			oi += 1
		else:
			print(even[ei], end='')
			ei += 1


def patate(n, l):
	for k in range(n):
		m = l[k]
		new = []
		for x in m:
			new.append(int(x))
		pair = []
		impair = []
		for x in new:
			if x % 2 == 0:
				pair.append(x)
			else:
				impair.append(x)
		new = fusion(pair, impair)
		mot = ''
		for x in new:
			mot += str(x)
		print(mot)

def fusion(a, b):
	i = 0
	j = 0
	new = []
	while len(a) != i and len(b) != j:
		if a[i] < b[j]:
			new.append(a[i])
			i += 1
		else:
			new.append(b[j])
			j += 1
	new = new + a[i:] + b[j:]
	return new
t = int(input())
l = [list(input()) for _ in range(t)]
patate(t, l)


for _ in range(int(input())):
	a = [int(i) for i in input()]
	even = [i for i in a if i % 2 == 0]
	odd = [i for i in a if i % 2 == 1]
	even.reverse()
	odd.reverse()
	new_a = []
	while even and odd:
		if even[-1] < odd[-1]:
			new_a.append(even.pop())
		else:
			new_a.append(odd.pop())
	even.reverse()
	odd.reverse()
	new_a.extend(even)
	new_a.extend(odd)
	print(*new_a, sep='')


for _ in range(int(input())):
	s = str(input())
	odd = []
	even = []
	ans = []
	for i in s:
		if int(i) % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	a = 0
	b = 0
	if len(odd) == 0 or len(even) == 0:
		print(s)
	else:
		while a < len(odd) or b < len(even):
			if a == len(odd):
				print(even[b], end='')
				b += 1
				continue
			elif b == len(even):
				print(odd[a], end='')
				a += 1
				continue
			elif odd[a] > even[b]:
				print(even[b], end='')
				b += 1
			elif odd[a] < even[b]:
				print(odd[a], end='')
				a += 1
			if a == len(odd) and b == len(even):
				break
		print()


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def get_list():
	return [int(i) for i in input().split()]

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	s = [int(i) for i in input().strip()]
	n = len(s)
	stack1 = []
	stack2 = []
	for i in s:
		if i % 2 == 0:
			stack1.append(i)
		else:
			stack2.append(i)
	iter1 = 0
	iter2 = 0
	ans = []
	while iter1 < len(stack1) and iter2 < len(stack2):
		if stack1[iter1] <= stack2[iter2]:
			ans.append(stack1[iter1])
			iter1 += 1
		else:
			ans.append(stack2[iter2])
			iter2 += 1
	while iter1 < len(stack1):
		ans.append(stack1[iter1])
		iter1 += 1
	while iter2 < len(stack2):
		ans.append(stack2[iter2])
		iter2 += 1
	ans = [str(i) for i in ans]
	print(''.join(ans))


for _ in range(int(input())):
	s = input()
	evens = []
	odds = []
	for c in s:
		if int(c) % 2:
			odds.append(c)
		else:
			evens.append(c)
	i = 0
	j = 0
	result = []
	while i < len(odds) and j < len(evens):
		if odds[i] < evens[j]:
			result.append(odds[i])
			i += 1
		else:
			result.append(evens[j])
			j += 1
	while i < len(odds):
		result.append(odds[i])
		i += 1
	while j < len(evens):
		result.append(evens[j])
		j += 1
	print(''.join(result))


q = int(input())
for u in range(q):
	ans = ''
	od = ''
	ev = ''
	s = input()
	for i in s:
		d = ord(i) - 48
		if d % 2 == 0:
			ev += i
		else:
			od += i
	odsz = len(od)
	evsz = len(s) - odsz
	cod = 0
	cev = 0
	while cod < odsz and cev < evsz:
		if ev[cev] < od[cod]:
			ans += ev[cev]
			cev += 1
		else:
			ans += od[cod]
			cod += 1
	while cod < odsz:
		ans += od[cod]
		cod += 1
	while cev < evsz:
		ans += ev[cev]
		cev += 1
	print(ans)


for _ in range(int(input())):
	arr = list(input())
	even = []
	odd = []
	for i in arr:
		i = int(i)
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	i = 0
	n = min(len(even), len(odd))
	ans = []
	e = 0
	o = 0
	while e < len(even) and o < len(odd):
		if even[e] < odd[o]:
			ans.append(even[e])
			e += 1
		else:
			ans.append(odd[o])
			o += 1
	while e < len(even):
		ans.append(even[e])
		e += 1
	while o < len(odd):
		ans.append(odd[o])
		o += 1
	x = ''
	for i in ans:
		x += str(i)
	print(x)


n = int(input())
for i in range(n):
	a = [int(y) for y in input()]
	(c, d) = ([], [])
	for x in a:
		if x % 2:
			d.append(x)
		else:
			c.append(x)
	ans = []
	(l1, l2) = (0, 0)
	while l1 < len(c) and l2 < len(d):
		if c[l1] < d[l2]:
			ans.append(c[l1])
			l1 += 1
		else:
			ans.append(d[l2])
			l2 += 1
	ans += c[l1:] + d[l2:]
	print(*ans, sep='')


t = int(input())
for i in range(t):
	chet = ''
	nechet = ''
	s = input()
	for k in s:
		if int(k) % 2 == 0:
			chet += k
		else:
			nechet += k
	ch_ind = 0
	nech_ind = 0
	flag = True
	if len(chet) == 0:
		print(nechet)
	elif len(nechet) == 0:
		print(chet)
	else:
		while flag:
			if chet[ch_ind] < nechet[nech_ind]:
				print(chet[ch_ind], end='')
				ch_ind += 1
				if ch_ind == len(chet):
					print(nechet[nech_ind:])
					flag = False
			else:
				print(nechet[nech_ind], end='')
				nech_ind += 1
				if nech_ind == len(nechet):
					print(chet[ch_ind:])
					flag = False


import sys, math, bisect
from collections import deque

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		s = str(input())
		ans = str()
		o = deque()
		e = deque()
		for k in range(len(s)):
			if int(s[k]) % 2 == 1:
				o.append(s[k])
			else:
				e.append(s[k])
		ans = ''
		while len(o) > 0 and len(e) > 0:
			if int(o[0]) < int(e[0]):
				ans += o.popleft()
			else:
				ans += e.popleft()
		while len(o) > 0:
			ans += o.popleft()
		while len(e) > 0:
			ans += e.popleft()
		print(ans)
main()


t = int(input())
a = []
for i in range(t):
	a.append(input())
for i in a:
	k = 0
	s = ''
	c = []
	d = []
	for j in i:
		if j == '0' and k == 0:
			s += '0'
		else:
			if j != '0':
				k = 1
			if int(j) % 2 == 0:
				c.append(int(j))
			else:
				d.append(int(j))
	h = 0
	for p in range(len(c)):
		w = c[p]
		m = 0
		q = h
		while q < len(d):
			if w <= d[q]:
				s += str(w)
				m = 1
				break
			else:
				s += str(d[q])
				q += 1
		h = q
		if m == 0:
			s += str(w)
	for q in range(h, len(d)):
		s += str(d[q])
	print(s)


n = int(input())
while n > 0:
	n -= 1
	a = input()
	s1 = ''
	s2 = ''
	for i in a:
		if int(i) & 1 == 0:
			s1 += i
		else:
			s2 += i
	i = 0
	j = 0
	n1 = len(s1)
	n2 = len(s2)
	ans = ''
	while i < n1 and j < n2:
		if int(s1[i]) < int(s2[j]):
			ans += s1[i]
			i += 1
		else:
			ans += s2[j]
			j += 1
	if i < n1:
		ans += s1[i:]
		i += 1
	if j < n2:
		ans += s2[j:]
		j += 1
	print(ans)


n = int(input())
for _ in range(n):
	l = list(map(int, input()))
	r = []
	c = []
	nc = []
	for x in l:
		if x % 2 == 0:
			c.append(x)
		else:
			nc.append(x)
	lc = len(c)
	lnc = len(nc)
	i = 0
	j = 0
	while i < lc and j < lnc:
		if c[i] < nc[j]:
			r.append(c[i])
			i += 1
		else:
			r.append(nc[j])
			j += 1
	if i < lc:
		r += c[i:]
	elif j < lnc:
		r += nc[j:]
	print(''.join(map(str, r)))


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())
t = intput()
for _ in range(t):
	a = input()
	oddbuff = []
	evenbuff = []
	for x in a:
		x = int(x)
		if x % 2:
			oddbuff.append(x)
		else:
			evenbuff.append(x)
	result = []
	oddx = 0
	evenx = 0
	while oddx < len(oddbuff) and evenx < len(evenbuff):
		if oddbuff[oddx] < evenbuff[evenx]:
			result.append(str(oddbuff[oddx]))
			oddx += 1
		else:
			result.append(str(evenbuff[evenx]))
			evenx += 1
	for i in range(oddx, len(oddbuff)):
		result.append(str(oddbuff[i]))
	for i in range(evenx, len(evenbuff)):
		result.append(str(evenbuff[i]))
	print(''.join(result))


for _ in range(int(input())):
	n = input()
	odd = []
	even = []
	for i in n:
		if int(i) % 2:
			odd.append(i)
		else:
			even.append(i)
	i = 0
	j = 0
	arr = []
	while i < len(odd) and j < len(even):
		if odd[i] < even[j]:
			arr.append(odd[i])
			i += 1
		else:
			arr.append(even[j])
			j += 1
	while i < len(odd):
		arr.append(odd[i])
		i += 1
	while j < len(even):
		arr.append(even[j])
		j += 1
	print(*arr, sep='')


import heapq
for _ in range(int(input())):
	n = input()
	(l, r) = ([], [])
	for i in n:
		if int(i) % 2 == 0:
			l.append(i)
		else:
			r.append(i)
	m = list(heapq.merge(l, r))
	print(''.join(m))


def oneLineArrayPrint(arr):
	print(''.join([str(x) for x in arr]))
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	a = [int(x) for x in input()]
	n = len(a)
	odd = []
	even = []
	for x in a:
		if x % 2 == 1:
			odd.append(x)
		else:
			even.append(x)
	op = 0
	ep = 0
	ans = []
	while True:
		if op < len(odd) and ep < len(even):
			if odd[op] < even[ep]:
				ans.append(odd[op])
				op += 1
			else:
				ans.append(even[ep])
				ep += 1
		elif op < len(odd):
			ans.append(odd[op])
			op += 1
		elif ep < len(even):
			ans.append(even[ep])
			ep += 1
		else:
			break
	oneLineArrayPrint(ans)


foo = []
n = int(input())
for i in range(n):
	s = []
	ss = input()
	for j in ss:
		s.append(j)
	a = ''
	d = []
	f = []
	for q in s:
		if int(q) % 2 == 0:
			d.append(q)
		else:
			f.append(q)
	di = 0
	fi = 0
	d.append(11)
	f.append(11)
	for j in range(len(s)):
		if int(d[di]) > int(f[fi]):
			a += f[fi]
			fi += 1
		else:
			a += d[di]
			di += 1
	foo.append(a)
for i in foo:
	print(i)


t = int(input())

def solve():
	s = input()
	e = []
	o = []
	for c in s:
		x = int(c)
		if x % 2 == 0:
			e.append(x)
		else:
			o.append(x)
	res = []
	i = 0
	j = 0
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			res.append(str(e[i]))
			i += 1
		else:
			res.append(str(o[j]))
			j += 1
	while i < len(e):
		res.append(str(e[i]))
		i += 1
	while j < len(o):
		res.append(str(o[j]))
		j += 1
	print(''.join(res))
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	num = list(map(int, input().strip()))
	odd = []
	evn = []
	for i in num:
		if i % 2 == 0:
			odd += [i]
		else:
			evn += [i]
	ans = []
	i = 0
	j = 0
	while len(ans) != len(num):
		if i == len(odd):
			ans += [str(evn[j])]
			j += 1
		elif j == len(evn):
			ans += [str(odd[i])]
			i += 1
		elif odd[i] < evn[j]:
			ans += [str(odd[i])]
			i += 1
		else:
			ans += [str(evn[j])]
			j += 1
	print(''.join(ans))


from functools import reduce
from sys import stdin
from bisect import bisect_left, bisect_right

def main():
	li = list(map(int, list(stdin.readline().strip())))
	odd = [x for x in li if x % 2 != 0]
	even = [x for x in li if x % 2 == 0]
	res = []
	(p1, p2) = (0, 0)
	while p1 < len(odd) or p2 < len(even):
		if p1 < len(odd) and (p2 == len(even) or odd[p1] < even[p2]):
			res.append(odd[p1])
			p1 += 1
		else:
			res.append(even[p2])
			p2 += 1
	print(''.join(map(str, res)))
[main() for _ in range(int(input()))]


import heapq
t = int(input())
for i in range(0, t):
	s = []
	d = []
	x = input()
	for i in x:
		c = int(i)
		if c % 2 == 0:
			s.append(c)
		else:
			d.append(c)
	arr = []
	arr = list(heapq.merge(s, d))
	for i in arr:
		print(i, end='')
	print()


for t in range(int(input())):
	n = str(input())
	n = list(n)
	even = []
	odd = []
	for i in range(len(n)):
		if int(n[i]) % 2 == 0:
			even.append(int(n[i]))
		else:
			odd.append(int(n[i]))
	(el, ol) = (len(even), len(odd))
	i = 0
	j = 0
	ans = []
	while i < el and j < ol:
		if even[i] < odd[j]:
			ans.append(str(even[i]))
			i += 1
		else:
			ans.append(str(odd[j]))
			j += 1
	if i != el:
		for i in range(i, el):
			ans.append(str(even[i]))
	if j != ol:
		for j in range(j, ol):
			ans.append(str(odd[j]))
	print(''.join(ans))


t = int(input())
for _ in range(t):
	a = list(input())
	evens = list()
	odds = list()
	answer = list()
	for c in a:
		if int(c) % 2 == 0:
			evens.append(c)
		else:
			odds.append(c)
	(i, j) = (0, 0)
	while i < len(evens) and j < len(odds):
		if evens[i] < odds[j]:
			answer.append(evens[i])
			i += 1
		else:
			answer.append(odds[j])
			j += 1
	else:
		answer.extend(evens[i:] + odds[j:])
	print(''.join(answer))


t = int(input())
for tc in range(t):
	s = [int(i) for i in list(input())]
	(evens, odds) = ([], [])
	for i in range(len(s)):
		if s[i] % 2:
			odds.append(i)
		else:
			evens.append(i)
	if not len(evens) or not len(odds):
		print(''.join([str(i) for i in s]))
		continue
	p1 = 0
	p2 = 0
	res = []
	while True:
		if s[evens[p1]] < s[odds[p2]]:
			res.append(s[evens[p1]])
			p1 += 1
		else:
			res.append(s[odds[p2]])
			p2 += 1
		if p1 == len(evens):
			for i in range(p2, len(odds)):
				res.append(s[odds[i]])
			break
		if p2 == len(odds):
			for i in range(p1, len(evens)):
				res.append(s[evens[i]])
			break
	print(''.join([str(i) for i in res]))


from collections import deque
for _ in range(int(input())):
	x = input()
	even = deque()
	odd = deque()
	for i in map(int, x):
		if i % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	ans = deque()
	while len(ans) < len(x):
		if len(even) == 0:
			ans.append(odd.popleft())
		elif len(odd) == 0:
			ans.append(even.popleft())
		elif even[0] < odd[0]:
			ans.append(even.popleft())
		else:
			ans.append(odd.popleft())
	print(''.join((str(i) for i in ans)))


for i in range(int(input())):
	a = [int(x) for x in list(input().strip())]
	odd = []
	even = []
	an = []
	for j in a:
		if j % 2:
			odd.append(j)
		else:
			even.append(j)
	(p, q) = (0, 0)
	for j in range(len(a)):
		if p == len(odd):
			an = an + even[q:]
			break
		elif q == len(even):
			an = an + odd[p:]
			break
		if odd[p] < even[q]:
			an.append(odd[p])
			p += 1
		else:
			an.append(even[q])
			q += 1
	print(*an, sep='')


import sys
input = sys.stdin.readline
t = int(input())
from collections import deque
for _ in range(t):
	a = list(map(int, list(input())[:-1]))
	gu = deque()
	ki = deque()
	for i in range(len(a)):
		if a[i] % 2 == 0:
			gu.append(a[i])
		else:
			ki.append(a[i])
	ans = []
	if ki:
		km = ki.popleft()
	else:
		km = float('inf')
	if gu:
		gm = gu.popleft()
	else:
		gm = float('inf')
	while gu or ki:
		if gm > km:
			ans.append(km)
			if ki:
				km = ki.popleft()
			else:
				km = float('inf')
		else:
			ans.append(gm)
			if gu:
				gm = gu.popleft()
			else:
				gm = float('inf')
	if km != float('inf') or gm != float('inf'):
		if km < gm:
			ans.append(km)
			km = float('inf')
		else:
			ans.append(gm)
			gm = float('inf')
	if km != float('inf'):
		ans.append(km)
	if gm != float('inf'):
		ans.append(gm)
	print(''.join(list(map(str, ans))))


def fun():
	s = input()
	odd = []
	even = []
	for i in s:
		if int(i) % 2 == 0:
			odd.append(i)
		else:
			even.append(i)
	l = 0
	r = 0
	odd_n = len(odd)
	even_n = len(even)
	while l < odd_n and r < even_n:
		if odd[l] < even[r]:
			print(odd[l], end='')
			l = l + 1
		else:
			print(even[r], end='')
			r = r + 1
	if l < odd_n:
		while l < odd_n:
			print(odd[l], end='')
			l = l + 1
	if r < even_n:
		while r < even_n:
			print(even[r], end='')
			r = r + 1
	print()
t = int(input())
while t != 0:
	fun()
	t = t - 1


for _ in range(int(input())):
	long = list(map(int, list(input())))
	odd = []
	even = []
	for n in long:
		if n % 2 == 1:
			odd.append(n)
		else:
			even.append(n)
	even.append(10)
	odd.append(11)
	i1 = 0
	i2 = 0
	for i in range(len(long)):
		if even[i1] < odd[i2]:
			print(even[i1], end='')
			i1 += 1
		else:
			print(odd[i2], end='')
			i2 += 1
	print()


t = int(input())
for i in range(t):
	s = input()
	even = []
	odd = []
	for c in s:
		if int(c) % 2 == 0:
			even.append(int(c))
		else:
			odd.append(int(c))
	e = 0
	o = 0
	while e != len(even) or o != len(odd):
		if e == len(even):
			print(odd[o], end='')
			o += 1
		elif o == len(odd):
			print(even[e], end='')
			e += 1
		elif even[e] < odd[o]:
			print(even[e], end='')
			e += 1
		else:
			print(odd[o], end='')
			o += 1
	print()


t = int(input())
while t > 0:
	t = t - 1
	li = [int(x) for x in input()]
	ev = [x for x in li if x % 2 == 0]
	odd = [x for x in li if x % 2 == 1]
	lev = len(ev)
	lodd = len(odd)
	point_ev = 0
	point_odd = 0
	res = []
	while point_ev < lev and point_odd < lodd:
		if ev[point_ev] < odd[point_odd]:
			res.append(ev[point_ev])
			point_ev = point_ev + 1
		else:
			res.append(odd[point_odd])
			point_odd = point_odd + 1
	res.extend(ev[point_ev:])
	res.extend(odd[point_odd:])
	for ele in res:
		print(ele, end='')
	print()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	A = [int(s) for s in input()]
	evens = [s for s in A if s % 2 == 0]
	odds = [s for s in A if s % 2 == 1]
	evens.reverse()
	odds.reverse()
	A = []
	while evens and odds:
		if evens[-1] < odds[-1]:
			A.append(evens.pop())
		else:
			A.append(odds.pop())
	while evens:
		A.append(evens.pop())
	while odds:
		A.append(odds.pop())
	return ''.join(map(str, A))
for _ in range(getInt()):
	print(solve())


t = int(input())
while t:
	t -= 1
	x = list(map(int, list(input())))
	a = []
	b = []
	for i in x:
		if i & 1:
			b.append(i)
		else:
			a.append(i)
	c = []
	i = j = 0
	m1 = len(a)
	m2 = len(b)
	while i < m1 and j < m2:
		if a[i] < b[j]:
			c.append(a[i])
			i += 1
		else:
			c.append(b[j])
			j += 1
	while i < m1:
		c.append(a[i])
		i += 1
	while j < m2:
		c.append(b[j])
		j += 1
	print(''.join(map(str, c)))


for t in range(int(input())):
	s = input()
	l = len(s)
	eve = ''
	odd = ''
	for i in range(l):
		if (ord(s[i]) - ord('0')) % 2 == 0:
			eve += s[i]
		else:
			odd += s[i]
	e0 = len(eve)
	o0 = len(odd)
	e = 0
	o = 0
	a = ''
	for i in range(l):
		if o == o0:
			a += eve[e]
			e += 1
		elif e == e0:
			a += odd[o]
			o += 1
		elif ord(eve[e]) > ord(odd[o]):
			a += odd[o]
			o += 1
		else:
			a += eve[e]
			e += 1
	print(a)


from collections import defaultdict
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	T = int(input())
	for i in range(T):
		n = list(input())
		N = len(n)
		ans = ''
		even = []
		odd = []
		for i in range(N):
			x = int(n[i])
			if x % 2 == 0:
				even.append(x)
			else:
				odd.append(x)
		even = even[::-1]
		odd = odd[::-1]
		ans = ''
		for i in range(N):
			if odd == []:
				ans += str(even.pop())
			elif even == []:
				ans += str(odd.pop())
			elif odd[-1] > even[-1]:
				ans += str(even.pop())
			else:
				ans += str(odd.pop())
		print(ans)
main()


t = int(input())
for numbers in range(t):
	a = input()
	even = []
	odd = []
	for numbers in a:
		if int(numbers) % 2 == 0:
			even.append(numbers)
		else:
			odd.append(numbers)
	answer = ''
	i = 0
	j = 0
	while i < len(even) and j < len(odd):
		if even[i] <= odd[j]:
			answer += even[i]
			i += 1
		else:
			answer += odd[j]
			j += 1
	if i == len(even):
		for numbers in range(j, len(odd)):
			answer += odd[numbers]
	if j == len(odd):
		for numbers in range(i, len(even)):
			answer += even[numbers]
	print(answer)


lst = []
n = int(input())
for i in range(n):
	a = list(input())
	lst2 = []
	lst3 = []
	lst4 = []
	for i in range(len(a)):
		if int(a[i]) % 2 == 0:
			lst2.append(int(a[i]))
		else:
			lst3.append(int(a[i]))
	i = 0
	j = 0
	while i != len(lst2) and j != len(lst3):
		if lst2[i] < lst3[j]:
			lst4.append(lst2[i])
			i += 1
		else:
			lst4.append(lst3[j])
			j += 1
	while i != len(lst2):
		lst4.append(lst2[i])
		i += 1
	while j != len(lst3):
		lst4.append(lst3[j])
		j += 1
	lst.append(lst4)
for i in lst:
	for j in i:
		print(j, end='')
	print()


import sys
input = sys.stdin.buffer.readline

def process(S):
	evens = []
	odds = []
	even_digits = set(['0', '2', '4', '6', '8'])
	odd_digits = set(['1', '3', '5', '7', '9'])
	for c in S:
		c = chr(c)
		if c in even_digits:
			evens.append(c)
		elif c in odd_digits:
			odds.append(c)
	answer = []
	i1 = 0
	i2 = 0
	for i in range(len(evens) + len(odds)):
		if i1 < len(evens) and (i2 >= len(odds) or evens[i1] < odds[i2]):
			answer.append(evens[i1])
			i1 += 1
		else:
			answer.append(odds[i2])
			i2 += 1
	return ''.join(answer)
t = int(input())
for i in range(t):
	S = input()
	sys.stdout.write(process(S) + '\n')


n = int(input())
for i in range(n):
	s = input()
	l = []
	p = []
	for i in s:
		if int(i) % 2 == 0:
			l.append(i)
		else:
			p.append(i)
	ans = ''
	(x, y) = (0, 0)
	t1 = len(l)
	t2 = len(p)
	while x < t1 and y < t2:
		if l[x] < p[y]:
			a = l[x]
			x += 1
		else:
			a = p[y]
			y += 1
		ans += a
	for i in range(y, t2):
		ans += p[i]
	for i in range(x, t1):
		ans += l[i]
	print(ans)


T = int(input())
for t in range(T):
	a = str(input())
	a_even = ''
	a_odd = ''
	minimized_a = ''
	for x in a:
		if int(x) % 2 == 0:
			a_even += x
		else:
			a_odd += x
	index_even = 0
	index_odd = 0
	while index_even < len(a_even) or index_odd < len(a_odd):
		if index_even >= len(a_even):
			minimized_a += a_odd[index_odd:]
			break
		elif index_odd >= len(a_odd):
			minimized_a += a_even[index_even:]
			break
		elif a_even[index_even] < a_odd[index_odd]:
			minimized_a += a_even[index_even]
			index_even += 1
		elif a_even[index_even] > a_odd[index_odd]:
			minimized_a += a_odd[index_odd]
			index_odd += 1
	print(minimized_a)


odd_s = ['1', '3', '5', '7', '9']

def is_odd(c):
	return c in odd_s
T = int(input())
for _ in range(T):
	s = input()
	odd = list(filter(is_odd, s))
	even = list(filter(lambda x: not is_odd(x), s))
	ans = []
	o = e = 0
	while o < len(odd) and e < len(even):
		if odd[o] < even[e]:
			ans.append(odd[o])
			o += 1
		else:
			ans.append(even[e])
			e += 1
	while o < len(odd):
		ans.append(odd[o])
		o += 1
	while e < len(even):
		ans.append(even[e])
		e += 1
	print(''.join(ans))


t = int(input())
for _ in range(t):
	s = input()
	e = ''
	o = ''
	for i in s:
		if int(i) % 2 == 0:
			e = e + i
		else:
			o = o + i
	ans = ''
	i = 0
	j = 0
	while i + j < len(s):
		if j < len(o) and i < len(e):
			if int(e[i]) < int(o[j]):
				ans = ans + e[i]
				i = i + 1
			else:
				ans = ans + o[j]
				j = j + 1
		elif j == len(o) and i < len(e):
			ans = ans + e[i]
			i = i + 1
		elif i == len(e) and j < len(o):
			ans = ans + o[j]
			j = j + 1
	print(ans)


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
pr = lambda x: x

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	for _ in range(int(input())):
		s = [int(i) for i in input()]
		A = deque()
		B = deque()
		for i in s:
			if i % 2:
				B.append(i)
			else:
				A.append(i)
		Ans = []
		while A and B:
			if A[0] < B[0]:
				Ans.append(A.popleft())
			else:
				Ans.append(B.popleft())
		Ans += A
		Ans += B
		Ans = [str(i) for i in Ans]
		print(''.join(Ans))
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	from aj import *
except:
	pass
solve()


t = int(input())
while t:
	t -= 1
	st = input()
	odd = []
	even = []
	for i in st:
		if int(i) % 2 == 1:
			odd.append(i)
		else:
			even.append(i)
	lodd = 0
	leven = 0
	a = len(odd)
	b = len(even)
	s = ''
	while lodd < a and leven < b:
		if odd[lodd] < even[leven]:
			s = s + odd[lodd]
			lodd += 1
		else:
			s = s + even[leven]
			leven += 1
	if lodd == a:
		s = s + ''.join(even[leven:])
	else:
		s = s + ''.join(odd[lodd:])
	print(s)


for _ in range(int(input())):
	a = input().strip()
	n = len(a)
	l1 = ''
	l0 = ''
	ans = ''
	for i in range(n):
		if int(a[i]) % 2 == 0:
			l0 += a[i]
		else:
			l1 += a[i]
	(i, j) = (0, 0)
	while i < len(l1) and j < len(l0):
		if int(l1[i]) < int(l0[j]):
			ans += l1[i]
			i += 1
		else:
			ans += l0[j]
			j += 1
	while i < len(l1):
		ans += l1[i]
		i += 1
	while j < len(l0):
		ans += l0[j]
		j += 1
	print(ans)


t = int(input())
for test in range(t):
	numS = input()
	num = []
	for e in numS:
		num.append(int(e))
	pares = []
	impares = []
	for i in range(len(num) - 1, -1, -1):
		e = num[i]
		if e % 2 == 0:
			pares.append(e)
		else:
			impares.append(e)
	ans = []
	i1 = len(pares) - 1
	i2 = len(impares) - 1
	while i1 >= 0 and i2 >= 0:
		ans.append(min(pares[i1], impares[i2]))
		if ans[-1] == pares[i1]:
			pares.pop()
			i1 -= 1
		else:
			impares.pop()
			i2 -= 1
	while i1 >= 0:
		ans.append(pares[i1])
		i1 -= 1
	while i2 >= 0:
		ans.append(impares[i2])
		i2 -= 1
	print(''.join(map(str, ans)))


mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
import random

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = inin()
	for _ in range(t):
		s = sin()
		a = []
		b = []
		for i in s:
			i = int(i)
			if i % 2 == 0:
				a.append(i)
			else:
				b.append(i)
		c = []
		i = j = 0
		while 1:
			if i < len(a) and j < len(b):
				if a[i] < b[j]:
					c.append(a[i])
					i += 1
				else:
					c.append(b[j])
					j += 1
			elif i < len(a):
				c.append(a[i])
				i += 1
			elif j < len(b):
				c.append(b[j])
				j += 1
			else:
				break
		print(*c, sep='')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


q = int(input())
for _ in range(q):
	s = list(input())
	n = len(s)
	even = []
	odd = []
	for i in range(n):
		s[i] = int(s[i])
		if s[i] % 2 == 0:
			even.append(s[i])
		else:
			odd.append(s[i])
	i = 0
	j = 0
	ans = []
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			ans.append(even[i])
			i += 1
		else:
			ans.append(odd[j])
			j += 1
	if i < len(even):
		k = i
		for i in range(k, len(even)):
			ans.append(even[i])
	else:
		k = j
		for i in range(k, len(odd)):
			ans.append(odd[i])
	for i in range(n):
		ans[i] = str(ans[i])
	print(''.join(ans))


for tc in [0] * int(input()):
	s = input()
	l = [int(i) for i in s]
	o = []
	e = []
	for i in l:
		if i % 2 == 0:
			e.append(str(i))
		else:
			o.append(str(i))
	i = 0
	j = 0
	a = []
	while i < len(o) and j < len(e):
		if e[j] < o[i]:
			a.append(str(e[j]))
			j += 1
		else:
			a.append(str(o[i]))
			i += 1
	las = ''.join(a) + ''.join(o[i:]) + ''.join(e[j:])
	print(las)


for t in range(int(input())):
	s = input()
	n = len(s)
	l = [int(j) for j in list(s)]
	o = []
	e = []
	for i in range(n):
		if l[i] % 2 == 0:
			e.append(l[i])
		else:
			o.append(l[i])
	i = 0
	j = 0
	ans = [0 for i in range(n)]
	while i < len(o) and j < len(e):
		if e[j] > o[i]:
			ans[i + j] = o[i]
			i += 1
		else:
			ans[i + j] = e[j]
			j += 1
	while i < len(o):
		ans[i + j] = o[i]
		i += 1
	while j < len(e):
		ans[i + j] = e[j]
		j += 1
	print(''.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	vals = [int(k) for k in input()]
	n = len(vals)
	evens = []
	odds = []
	for s in range(n):
		if vals[s] % 2 == 0:
			evens.append(vals[s])
		else:
			odds.append(vals[s])
	evens.reverse()
	odds.reverse()
	ans = []
	while len(evens) > 0 or len(odds) > 0:
		if len(evens) > 0 and len(odds) > 0:
			if evens[-1] <= odds[-1]:
				ans.append(evens.pop())
			else:
				ans.append(odds.pop())
		elif len(evens) > 0:
			ans.append(evens.pop())
		else:
			ans.append(odds.pop())
	ans = [str(k) for k in ans]
	print(''.join(ans))


for _ in range(int(input())):
	s = input()
	n = len(s)
	o = ''
	e = ''
	lo = 0
	le = 0
	for i in range(n):
		if int(s[i]) % 2:
			o += s[i]
			lo += 1
		else:
			e += s[i]
			le += 1
	if lo == 0 or le == 0:
		ans = o + e
	else:
		ans = ''
		mi = min(lo, le)
		i = 0
		j = 0
		while i < le and j < lo:
			if e[i] < o[j]:
				ans += e[i]
				i += 1
			else:
				ans += o[j]
				j += 1
		ans += e[i:]
		ans += o[j:]
	print(ans)


for __ in range(int(input())):
	a = list(map(int, input()))
	ar1 = []
	ar2 = []
	for elem in a:
		if elem % 2 == 0:
			ar1.append(elem)
		else:
			ar2.append(elem)
	ans = []
	i = 0
	j = 0
	while i < len(ar1) and j < len(ar2):
		if ar1[i] < ar2[j]:
			ans.append(ar1[i])
			i += 1
		else:
			ans.append(ar2[j])
			j += 1
	if i < len(ar1):
		for h in range(i, len(ar1)):
			ans.append(ar1[h])
	if j < len(ar2):
		for h in range(j, len(ar2)):
			ans.append(ar2[h])
	print(''.join(map(str, ans)))


t = int(input())
for _ in range(t):
	n = input()
	even = []
	odd = []
	for i in n:
		if int(i) % 2 == 0:
			even.append(int(i))
		else:
			odd.append(int(i))
	i = j = 0
	e = len(even)
	o = len(odd)
	ans = ''
	while i < e and j < o:
		if even[i] <= odd[j]:
			ans = ans + str(even[i])
			i += 1
		else:
			ans = ans + str(odd[j])
			j += 1
	if i == e and j != o:
		while j < o:
			ans = ans + str(odd[j])
			j += 1
	elif j == o and i != e:
		while i < e:
			ans = ans + str(even[i])
			i += 1
	print(ans)


n = int(input())
for i in range(n):
	s = input()
	odds = []
	evens = []
	ans = []
	for i in range(len(s)):
		digi = ord(s[i]) - 48
		if digi % 2 == 0:
			evens.append(digi)
		else:
			odds.append(digi)
	l1 = len(odds)
	l2 = len(evens)
	idx1 = 0
	idx2 = 0
	while idx1 < l1 and idx2 < l2:
		if odds[idx1] < evens[idx2]:
			ans.append(odds[idx1])
			idx1 += 1
		else:
			ans.append(evens[idx2])
			idx2 += 1
	while idx1 < l1:
		ans.append(odds[idx1])
		idx1 += 1
	while idx2 < l2:
		ans.append(evens[idx2])
		idx2 += 1
	tmp = [str(i) for i in ans]
	tmp = ''.join(tmp)
	print(tmp)


def parity(n):
	n = int(n)
	if n % 2 == 0:
		return 'EVEN'
	else:
		return 'ODD'

def swap(n):
	even_lst = []
	odd_lst = []
	for i in n:
		if parity(i) == 'EVEN':
			even_lst.append(i)
		else:
			odd_lst.append(i)
	out = []
	(o, e) = (0, 0)
	ol = len(odd_lst)
	el = len(even_lst)
	while o < ol and e < el:
		if odd_lst[o] < even_lst[e]:
			out.append(odd_lst[o])
			o += 1
		else:
			out.append(even_lst[e])
			e += 1
	out += odd_lst[o:]
	out += even_lst[e:]
	s = ''
	return s.join(out)
lst = []
test = int(input())
for i in range(test):
	x = input()
	lst.append(x)
for i in lst:
	print(swap(i))


for _ in range(int(input())):
	s = input()
	a = []
	b = []
	for i in s:
		temp = int(i)
		if temp % 2:
			a.append(temp)
		else:
			b.append(temp)
	i = 0
	j = 0
	res = ''
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			res += str(a[i])
			i += 1
		else:
			res += str(b[j])
			j += 1
	while i < len(a):
		res += str(a[i])
		i += 1
	while j < len(b):
		res += str(b[j])
		j += 1
	print(res)


q = int(input())
inputlist = []
for j in range(q):
	m = str(input())
	inputlist.append(m)

def minimize(strint):
	intlist = []
	for j in strint:
		intlist.append(j)
	evelist = []
	oddlist = []
	for j in intlist:
		if int(j) % 2 == 0:
			evelist.append(j)
		else:
			oddlist.append(j)
	answerstr = ''
	i = 0
	j = 0
	while i < len(evelist) and j < len(oddlist):
		if int(evelist[i]) < int(oddlist[j]):
			answerstr += str(evelist[i])
			i += 1
		else:
			answerstr += str(oddlist[j])
			j += 1
	if i <= len(evelist) - 1:
		for k in range(i, len(evelist)):
			answerstr += str(evelist[k])
	if j <= len(oddlist) - 1:
		for k in range(j, len(oddlist)):
			answerstr += str(oddlist[k])
	return answerstr
for j in inputlist:
	print(minimize(j))


t = int(input())
for _ in range(t):
	a = list(map(int, list(input())))
	b = [i for i in a if i % 2 == 0]
	c = [i for i in a if i % 2 == 1]
	ind = 0
	ind2 = 0
	ans = []
	while ind < len(b) and ind2 < len(c):
		if b[ind] < c[ind2]:
			ans.append(b[ind])
			ind += 1
		else:
			ans.append(c[ind2])
			ind2 += 1
	if ind < len(b):
		ans += b[ind:]
	if ind2 < len(c):
		ans += c[ind2:]
	for i in ans:
		print(i, end='')
	print()


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
t = oint()
for _ in range(t):
	even = []
	odd = []
	a = input()
	for i in range(len(a)):
		ai = int(a[i])
		if ai % 2:
			odd.append(ai)
		else:
			even.append(ai)
	ee = len(even)
	oe = len(odd)
	oi = 0
	ei = 0
	ans = []
	while ei < ee or oi < oe:
		if ei == ee:
			for i in range(oi, oe):
				ans.append(str(odd[i]))
			break
		if oi == oe:
			for i in range(ei, ee):
				ans.append(str(even[i]))
			break
		if odd[oi] > even[ei]:
			ans.append(str(even[ei]))
			ei += 1
		else:
			ans.append(str(odd[oi]))
			oi += 1
	print(''.join(map(str, ans)))


from sys import stdin, stdout
for j in range(int(stdin.readline())):
	even = []
	odd = []
	for i in input():
		odd.append(ord(i) - 48) if (ord(i) - 48) % 2 else even.append(ord(i) - 48)
	oc = 0
	ec = 0
	ol = len(odd)
	el = len(even)
	while oc < ol and ec < el:
		if odd[oc] < even[ec]:
			print(odd[oc], end='')
			oc += 1
		else:
			print(even[ec], end='')
			ec += 1
	if oc == ol and ec != el:
		for i in range(ec, el):
			print(even[i], end='')
	elif oc != ol and ec == el:
		for i in range(oc, ol):
			print(odd[i], end='')
	print()


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
for i in range(t):
	ls = list(map(int, list(input())))
	odd = []
	even = []
	for i in ls:
		if i % 2:
			odd.append(i)
		else:
			even.append(i)
	i = 0
	j = 0
	ans = []
	while i < len(odd) and j < len(even):
		if odd[i] < even[j]:
			ans.append(odd[i])
			i += 1
		elif odd[i] > even[j]:
			ans.append(even[j])
			j += 1
	if i == len(odd):
		while j < len(even):
			ans.append(even[j])
			j += 1
	else:
		while i < len(odd):
			ans.append(odd[i])
			i += 1
	print(''.join(map(str, ans)))


a = int(input())
for i in range(0, a):
	arr = input()
	arr = [int(i) for i in arr]
	brr = [i % 2 for i in arr]
	even = []
	odd = []
	for i in arr:
		if i % 2 == 1:
			odd.append(i)
		else:
			even.append(i)
	ans = []
	ce = 0
	co = 0
	for i in range(0, len(arr)):
		if ce >= len(even):
			ans.append(odd[co])
			co = co + 1
		elif co >= len(odd):
			ans.append(even[ce])
			ce = ce + 1
		elif even[ce] > odd[co]:
			ans.append(odd[co])
			co = co + 1
		else:
			ans.append(even[ce])
			ce = ce + 1
	print(''.join(map(str, ans)))


from collections import deque
t = int(input())
for i in range(t):
	num = input()
	q = deque([int(num[0])])
	result = []
	for digit in num[1:]:
		x = int(digit)
		if q[-1] % 2 != x % 2:
			while len(q) > 0 and q[0] < x:
				result.append(q[0])
				q.popleft()
			if len(q) > 0:
				result.append(x)
			else:
				q.append(x)
		else:
			q.append(x)
	while len(q) > 0:
		result.append(q.popleft())
	print(''.join([str(i) for i in result]))


t = int(input())
for i in range(t):
	a = input()
	aodd = ''
	aeven = ''
	out = ''
	po = 0
	pe = 0
	for i in a:
		if int(i) % 2 == 1:
			aodd += i
		else:
			aeven += i
	while po != len(aodd) or pe != len(aeven):
		if po == len(aodd):
			out += aeven[pe:]
			break
		elif pe == len(aeven):
			out += aodd[po:]
			break
		elif int(aodd[po]) > int(aeven[pe]):
			out += aeven[pe]
			pe += 1
		else:
			out += aodd[po]
			po += 1
	print(out)


t = int(input())
for _ in range(0, t):
	s = [i for i in input()]
	ee = []
	oo = []
	ans = []
	for i in s:
		if int(i) & 1:
			oo += [i]
		else:
			ee += [i]
	(o, e) = (0, 0)
	while o < len(oo) and e < len(ee):
		if oo[o] < ee[e]:
			ans += [oo[o]]
			o += 1
		else:
			ans += [ee[e]]
			e += 1
	ans += ee[e:] + oo[o:]
	print(''.join(ans))


def main():
	lines = int(input())
	for i in range(lines):
		(odd, even) = (list(), list())
		result = ''
		number = list(str(input()))
		for letter in number:
			buff = int(letter)
			if buff % 2:
				odd.append(letter)
			else:
				even.append(letter)
		(i, j) = (0, 0)
		(even_size, odd_size) = (len(even), len(odd))
		while i < even_size or j < odd_size:
			if i < even_size and j < odd_size:
				if even[i] < odd[j]:
					result += even[i]
					i += 1
				else:
					result += odd[j]
					j += 1
			elif i < even_size:
				result += even[i]
				i += 1
			else:
				result += odd[j]
				j += 1
		print(result)
main()


for _ in range(int(input())):
	l = list(map(int, input()))
	q1 = []
	q2 = []
	for t in l:
		if t % 2:
			q2.append(t)
		else:
			q1.append(t)
	k1 = 0
	k2 = 0
	ans = []
	while k1 < len(q1) and k2 < len(q2):
		a = q1[k1]
		b = q2[k2]
		if a < b:
			ans.append(a)
			k1 += 1
		else:
			ans.append(b)
			k2 += 1
	for i in range(k1, len(q1)):
		ans.append(q1[i])
	for j in range(k2, len(q2)):
		ans.append(q2[j])
	print(*ans, sep='')


t = int(input())
for i in range(t):
	s = input()
	sl = list(s)
	so = []
	se = []
	for j in range(len(sl)):
		if int(sl[j]) % 2 == 1:
			so.append(sl[j])
		else:
			se.append(sl[j])
	ans = ''
	el = 0
	ol = 0
	leno = len(so)
	lene = len(se)
	while ol != leno or el != lene:
		if ol == leno:
			ans += se[el]
			el += 1
		elif el == lene:
			ans += so[ol]
			ol += 1
		elif se[el] <= so[ol]:
			ans += se[el]
			el += 1
		else:
			ans += so[ol]
			ol += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		a = list(input())
		n = len(a)
		odd = []
		even = []
		res = []
		for i in range(n):
			if int(a[i]) % 2:
				odd.append(a[i])
			else:
				even.append(a[i])
		i = 0
		j = 0
		while i < len(odd) and j < len(even):
			if odd[i] < even[j]:
				res.append(odd[i])
				i += 1
			else:
				res.append(even[j])
				j += 1
		while i < len(odd):
			res.append(odd[i])
			i += 1
		while j < len(even):
			res.append(even[j])
			j += 1
		print(''.join(res))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


q = int(input())
for _ in range(q):
	s0 = ''
	s1 = ''
	s = input()
	ans = ''
	for c in s:
		if ord(c) % 2 == 1:
			s1 = s1 + c
		else:
			s0 = s0 + c
	l0 = 0
	l1 = 0
	while len(s0) > l0 and len(s1) > l1:
		if s0[l0] > s1[l1]:
			ans = ans + s1[l1]
			l1 = l1 + 1
		else:
			ans = ans + s0[l0]
			l0 = l0 + 1
	print(ans + s1[l1:] + s0[l0:])


q = int(input())
arr = []
for _ in range(q):
	s = input()
	a = [int(x) for x in s]
	l = []
	c = []
	ans = []
	for (i, x) in enumerate(a):
		if x % 2 == 0:
			c.append(x)
		else:
			l.append(x)
	(i, j) = (0, 0)
	while i < len(l) and j < len(c):
		if l[i] < c[j]:
			ans.append(l[i])
			i += 1
		else:
			ans.append(c[j])
			j += 1
	while i < len(l):
		ans.append(l[i])
		i += 1
	while j < len(c):
		ans.append(c[j])
		j += 1
	arr.append(''.join([str(x) for x in ans]))
print('\n'.join([x for x in arr]))


for _ in range(int(input())):
	s = input()
	e = []
	o = []
	for i in s:
		if int(i) % 2 == 0:
			e.append(int(i))
		else:
			o.append(int(i))
	i = 0
	j = 0
	ans = ''
	while i < len(e) and j < len(o):
		if e[i] < o[j]:
			ans += str(e[i])
			i += 1
		else:
			ans += str(o[j])
			j += 1
	for k in range(i, len(e)):
		ans += str(e[k])
	for k in range(j, len(o)):
		ans += str(o[k])
	print(ans)


t = int(input())
for i in range(t):
	s = list(input())
	i = 0
	odd = []
	even = []
	for i in s:
		if int(i) % 2 == 0:
			even.append(i)
		else:
			odd.append(i)
	i = 0
	j = 0
	k = 0
	m = ['' for i in range(len(s))]
	while i < len(even) and j < len(odd):
		if int(even[i]) < int(odd[j]):
			m[k] = even[i]
			k += 1
			i += 1
		else:
			m[k] = odd[j]
			k += 1
			j += 1
	while i < len(even):
		m[k] = even[i]
		k += 1
		i += 1
	while j < len(odd):
		m[k] = odd[j]
		k += 1
		j += 1
	print(''.join(m))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	s = sys.stdin.readline()[:-1]
	even = []
	odd = []
	n = len(s)
	for i in range(n):
		if int(s[i]) % 2 == 0:
			even.append(s[i])
		else:
			odd.append(s[i])
	(i, j) = (0, 0)
	ans = [0 for _ in range(n)]
	k = 0
	(e, o) = (len(even), len(odd))
	while i < e and j < o:
		if even[i] < odd[j]:
			ans[k] = even[i]
			k += 1
			i += 1
		else:
			ans[k] = odd[j]
			k += 1
			j += 1
	while i < e:
		ans[k] = even[i]
		k += 1
		i += 1
	while j < o:
		ans[k] = odd[j]
		k += 1
		j += 1
	print(''.join((str(x) for x in ans)))


n = int(input())

def canSwap(a, b):
	return not a % 2 == b % 2
for _ in range(n):
	number = [*map(int, list(input()))]
	oddDigits = []
	evenDigits = []
	for digit in number:
		oddDigits.append(digit) if digit % 2 != 0 else evenDigits.append(digit)
	oddPtr = 0
	evenPtr = 0
	number = []
	while oddPtr < len(oddDigits) or evenPtr < len(evenDigits):
		if oddPtr == len(oddDigits):
			while evenPtr < len(evenDigits):
				number.append(evenDigits[evenPtr])
				evenPtr += 1
		elif evenPtr == len(evenDigits):
			while oddPtr < len(oddDigits):
				number.append(oddDigits[oddPtr])
				oddPtr += 1
		elif oddDigits[oddPtr] < evenDigits[evenPtr]:
			number.append(oddDigits[oddPtr])
			oddPtr += 1
		else:
			number.append(evenDigits[evenPtr])
			evenPtr += 1
	print(''.join(map(str, number)))


t = int(input())
for i in range(t):
	w = [int(k) for k in input()]
	(a, b) = ([], [])
	for j in w:
		if j % 2 == 0:
			a.append(j)
		else:
			b.append(j)
	a = a[::-1]
	b = b[::-1]
	res = ''
	c = len(w)
	for j in range(c):
		try:
			if a[-1] < b[-1]:
				res += str(a.pop())
			else:
				res += str(b.pop())
		except:
			if a:
				for k in range(len(a)):
					res += str(a.pop())
			else:
				for k in range(len(b)):
					res += str(b.pop())
			break
	print(res)


from collections import deque

def move(t):
	od = deque()
	ev = deque()
	for x in t:
		if int(x) % 2:
			od.append(x)
		else:
			ev.append(x)
	ans = list()
	while od and ev:
		if od[0] < ev[0]:
			ans.append(od.popleft())
		else:
			ans.append(ev.popleft())
	ans += od
	ans += ev
	return ''.join(ans)
q = int(input())
for _ in range(q):
	print(move(input()))


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	a = [int(i) for i in input()]
	odd = [i for i in a if i % 2]
	even = [i for i in a if not i % 2]
	i = 0
	j = 0
	ans = []
	while i < len(even) and j < len(odd):
		if even[i] < odd[j]:
			ans.append(even[i])
			i += 1
		else:
			ans.append(odd[j])
			j += 1
	ans += even[i:] + odd[j:]
	print(*ans, sep='')


t = int(input())
ks = []
for i in range(t):
	ks.append(input())
for i in range(t):
	tar = ks[i]
	gu = []
	ki = []
	l_t = len(tar)
	for m in range(l_t):
		i_m = int(tar[m])
		if i_m % 2 == 0:
			gu.append(i_m)
		else:
			ki.append(i_m)
	ans = ''
	g_l = len(gu)
	k_l = len(ki)
	g_t = 0
	k_t = 0
	while True:
		if g_t > g_l - 1:
			ans += str(ki[k_t])
			k_t += 1
		elif k_t > k_l - 1:
			ans += str(gu[g_t])
			g_t += 1
		elif gu[g_t] < ki[k_t]:
			ans += str(gu[g_t])
			g_t += 1
		else:
			ans += str(ki[k_t])
			k_t += 1
		if g_t + k_t == l_t:
			break
	print(ans)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
for _ in range(INT()):
	A = list(map(int, list(input())))
	N = len(A)
	odd = []
	even = []
	for a in A:
		if a % 2 == 0:
			even.append(a)
		else:
			odd.append(a)
	odd = odd[::-1]
	even = even[::-1]
	ans = []
	while odd and even:
		if odd[-1] < even[-1]:
			ans.append(odd.pop())
		else:
			ans.append(even.pop())
	while odd:
		ans.append(odd.pop())
	while even:
		ans.append(even.pop())
	ans = list(map(str, ans))
	print(''.join(ans))


t = int(input())
for _ in range(t):
	a = [int(i) for i in input()]
	n = len(a)
	even = [i for i in a if not i & 1]
	odd = [i for i in a if i & 1]
	even = even[::-1]
	odd = odd[::-1]
	res = ''
	while len(res) < n:
		if even and odd:
			nxt = min(even[-1], odd[-1])
			res += str(nxt)
			if nxt == even[-1]:
				even.pop()
			else:
				odd.pop()
		elif even:
			nxt = even[-1]
			res += str(nxt)
			even.pop()
		else:
			nxt = odd[-1]
			res += str(nxt)
			odd.pop()
	print(res)


from collections import deque
t = int(input())
for _ in range(t):
	s = input()
	s_even = deque()
	s_odd = deque()
	for si in s:
		si = int(si)
		if si % 2 == 0:
			s_even.append(si)
		else:
			s_odd.append(si)
	res = []
	while len(s_even) != 0 and len(s_odd) != 0:
		if s_even[0] > s_odd[0]:
			res.append(str(s_odd.popleft()))
		else:
			res.append(str(s_even.popleft()))
	res.extend((str(x) for x in s_odd))
	res.extend((str(x) for x in s_even))
	print(''.join(res))


cases = int(input())
for _ in range(cases):
	line = input()
	evens = []
	odds = []
	for c in line:
		if int(c) % 2 == 0:
			evens.append(c)
		else:
			odds.append(c)
	oddI = 0
	evenI = 0
	arr = []
	while True:
		if oddI < len(odds) and evenI < len(evens):
			if odds[oddI] < evens[evenI]:
				arr.append(odds[oddI])
				oddI += 1
			else:
				arr.append(evens[evenI])
				evenI += 1
		elif oddI < len(odds):
			arr.append(odds[oddI])
			oddI += 1
		elif evenI < len(evens):
			arr.append(evens[evenI])
			evenI += 1
		else:
			break
	for n in arr:
		print(n, end='')
	print()


t = int(input(''))
for _ in range(t):
	a = input('')
	n = len(a)
	o = []
	e = []
	for i in range(n):
		if int(a[i]) % 2 == 0:
			e.append(int(a[i]))
		else:
			o.append(int(a[i]))
	ans = []
	i = 0
	j = 0
	lo = len(o)
	le = len(e)
	while i < lo and j < le:
		if o[i] < e[j]:
			ans.append(o[i])
			i = i + 1
		else:
			ans.append(e[j])
			j = j + 1
	if i == lo:
		ans = ans + e[j:]
	elif j == le:
		ans = ans + o[i:]
	for nu in ans:
		print(nu, end='')
	print('')


mans = ''
for _ in range(int(input())):
	s = input()
	ev = ''
	od = ''
	for x in s:
		if x in '13579':
			od += x
		else:
			ev += x
	ans = ''
	uv = 0
	ud = 0
	while uv < len(ev) or ud < len(od):
		if uv == len(ev):
			ans += od[ud]
			ud += 1
		elif ud == len(od):
			ans += ev[uv]
			uv += 1
		elif ev[uv] < od[ud]:
			ans += ev[uv]
			uv += 1
		else:
			ans += od[ud]
			ud += 1
	mans += ans
	mans += '\n'
print(mans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	for _ in range(N()):
		s = input()
		a = []
		b = []
		for i in s:
			if int(i) % 2 == 1:
				a.append(int(i))
			else:
				b.append(int(i))
		(pa, pb) = (0, 0)
		res = []
		for i in range(len(s)):
			if pa == len(a):
				res.append(b[pb])
				pb += 1
			elif pb == len(b):
				res.append(a[pa])
				pa += 1
			elif a[pa] < b[pb]:
				res.append(a[pa])
				pa += 1
			else:
				res.append(b[pb])
				pb += 1
		print(''.join([str(i) for i in res]))
main()