added sorting to canvas class