code: private List<AggregationHashChain> sortAggregationHashChains(List<AggregationHashChain> chains) throws InvalidSignatureException {
          Collections.sort(chains, new Comparator<AggregationHashChain>() {
              public int compare(AggregationHashChain chain1, AggregationHashChain chain2) {
                  return chain2.getChainIndex().size() - chain1.getChainIndex().size();
              }
          });
          return chains;
      }
docs: Orders aggregation chains.
  
  @param chains
  aggregation chains to be ordered.
  @return ordered list of aggregation chains