sort k increasing or cecreasing array