somewhat working sorting