Update on finding gradient.
Added bucket sort for gradients.