code: private void orderResults(ResultSet cqlRows) throws InvalidRequestException
      {
          if (cqlRows.size() == 0 || !needsPostQueryOrdering())
              return;
  
          assert orderingIndexes != null;
  
          List<Integer> idToSort = new ArrayList<Integer>();
          List<Comparator<ByteBuffer>> sorters = new ArrayList<Comparator<ByteBuffer>>();
  
          for (ColumnIdentifier.Raw identifier : parameters.orderings.keySet())
          {
              ColumnDefinition orderingColumn = cfm.getColumnDefinition(identifier.prepare(cfm));
              idToSort.add(orderingIndexes.get(orderingColumn.name));
              sorters.add(orderingColumn.type);
          }
  
          Comparator<List<ByteBuffer>> comparator = idToSort.size() == 1
                                                  ? new SingleColumnComparator(idToSort.get(0), sorters.get(0))
                                                  : new CompositeComparator(sorters, idToSort);
          Collections.sort(cqlRows.rows, comparator);
      }
docs: Orders results when multiple keys are selected (using IN)