I was going through the chatbot tutorial and saw the following:
    pair_batch.sort(key=lambda x: len(x[0].split(" ")), reverse=True)

why does the tutorial (reverse) sort? Is there a good reason?

code:
# Returns all items for a given batch of pairs
def batch2TrainData(voc, pair_batch):
    '''
    '''
    pair_batch.sort(key=lambda x: len(x[0].split(" ")), reverse=True)
    #print( [len(pair[0].split(" ")) for pair in pair_batch] )
    #st()
    input_batch, output_batch = [], []
    # seperate the pairs (for the current batch) in X and Y values
    for pair in pair_batch:
        input_batch.append(pair[0])
        output_batch.append(pair[1])
    # returns a matrix of (max_length,batch_size) corresponding to the feature vectors X
    inp, lengths = inputVar(input_batch, voc)
    output, mask, max_target_len = outputVar(output_batch, voc)
    return inp, lengths, output, mask, max_target_len