updated to sort points for matplotlib, allowing for connecting of points