<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sort_by_list_order(sortlist, reflist, reverse=False, fltr=False, slemap=None):
 """ Sort a list according to the order of entries in a reference list. Parameters sortlist : list List to be sorted reflist : list Reference list defining sorting order reverse : bool, optional (default False) Flag indicating whether to sort in reverse order fltr : bool, optional (default False) Flag indicating whether to filter `sortlist` to remove any entries that are not in `reflist` slemap : function or None, optional (default None) Function mapping a sortlist entry to the form of an entry in `reflist` Returns ------- sortedlist : list Sorted (and possibly filtered) version of sortlist """


    def keyfunc(entry):
        if slemap is not None:
            rle = slemap(entry)
        if rle in reflist:
            # Ordering index taken from reflist
            return reflist.index(rle)
        else:
            # Ordering index taken from sortlist, offset
            # by the length of reflist so that entries
            # that are not in reflist retain their order
            # in sortlist
            return sortlist.index(entry) + len(reflist)

    if fltr:
        if slemap:
            sortlist = filter(lambda x: slemap(x) in reflist, sortlist)
        else:
            sortlist = filter(lambda x: x in reflist, sortlist)

    return sorted(sortlist, key=keyfunc, reverse=reverse)