rudimentary sorting in place