code: @SuppressWarnings("rawtypes")
      protected SortKey getSortKey(JTable table, int column) {
          RowSorter rowSorter = table.getRowSorter();
          if (rowSorter == null) {
              return null;
          }
  
          List sortedColumns = rowSorter.getSortKeys();
          if (!sortedColumns.isEmpty()) {
              return (SortKey) sortedColumns.get(0);
          }
          return null;
      }
docs: Returns the current sort key, or null if the column is unsorted.
  
  @param table the table
  @param column the column index
  @return the SortKey, or null if the column is unsorted