Bug Fix in sorting data points