import locale


def sortSections(sectionList):
    """ sorting sections. The proper order is:
    1. "użycie międzynarodowe"
    2. "polski"
    3. "termin obcy w języku polskim"
    4. "znak chiński"
    The rest is sorted alphabetically with pl_PL locale
    
    @param sectionList: a list of language sections to be sorted
    @type sectionList: list of LanguageSection() objects
    
    """
    
    sectionList = sorted(sectionList, key=lambda x: locale.strxfrm(x.lang))
    
    for lang in ['znak chiński', 'termin obcy w języku polskim', 'polski', 'użycie międzynarodowe']:
        for sec in sectionList:
            if sec.lang == lang:
                ind = sectionList.index(sec)
                sectionList.insert(0, sectionList.pop(ind))

    return sectionList