added sortedArray and reversedArray