code: private static void sortEventsByTokenIndex(Row row) {
      Collections.sort(row.getEvents(), new Comparator<GridEvent>() {
        @Override
        public int compare(GridEvent o1, GridEvent o2) {
          if (o1 == o2) {
            return 0;
          }
          if (o1 == null) {
            return -1;
          }
          if (o2 == null) {
            return +1;
          }
  
          return Integer.compare(o1.getLeft(), o2.getLeft());
        }
      });
    }
docs: Sort events of a row. The sorting is depending on the left value of the
  event
  
  @param row