Adds actual implementation for sorting. Other methods may need to be converted to this.