Added array sorting functions