def word_sorter(x):  
    """
    Function to sort the word frequency pairs after frequency
    Lowest frequency collocates first - highest frerquency collocates last
    """
    # getting length of list of word/frequency pairs 
    lst = len(x)  

    # sort by frequency
    for i in range(0, lst):    
        for j in range(0, lst-i-1):  
            if (x[j][1] > x[j + 1][1]):  
                temp = x[j]  
                x[j]= x[j + 1]  
                x[j + 1] = temp  
    return(x)