sorting method for graphic