quadratic runtime sorting