Creating a method to sort arrays from scratch