*order tasks within this taskpaper object via a list of tags*

        The order of the tags in the list dictates the order of the sort - first comes first*

        **Key Arguments:**
            - ``workflowTags`` -- a string of space seperated tags.

        **Return:**
            - ``None``

        **Usage:**

            To recursively sort the tasks within a taskpaper document with the following order:

            1. *@due*
            2. *@flag*
            3. *@hold*
            4. *@next*
            5. *@someday*
            6. *@wait*

            use the following:

            .. code-block:: python

                doc.sort_tasks("@due, @flag, @hold, @next, @someday, @wait")

def sort_tasks(
            self,
            workflowTags,
            indentLevel=1):
        """*order tasks within this taskpaper object via a list of tags*

        The order of the tags in the list dictates the order of the sort - first comes first*

        **Key Arguments:**
            - ``workflowTags`` -- a string of space seperated tags.

        **Return:**
            - ``None``

        **Usage:**

            To recursively sort the tasks within a taskpaper document with the following order:

            1. *@due*
            2. *@flag*
            3. *@hold*
            4. *@next*
            5. *@someday*
            6. *@wait*

            use the following:

            .. code-block:: python

                doc.sort_tasks("@due, @flag, @hold, @next, @someday, @wait")
        """
        self.refresh
        if not isinstance(workflowTags, list):
            workflowTagsLists = workflowTags.strip().replace(",", "").replace("@", "")
            workflowTagsLists = workflowTagsLists.split(" ")
        else:
            workflowTagsLists = []
            workflowTagsLists[:] = [l.replace("@", "") for l in workflowTags]
        matchedTasks = collections.OrderedDict(sorted({}.items()))
        unmatchedTasks = []

        for wt in workflowTagsLists:
            matchedTasks[wt.lower()] = []
        for t in self.tasks:
            matched = False
            for tt in t.tags:
                if matched:
                    break
                for wt in workflowTagsLists:
                    thisTag = tt.lower()
                    if "(" not in wt:
                        thisTag = tt.split("(")[0].lower()
                    if thisTag == wt.lower() and matched == False:
                        matchedTasks[wt.lower()].append(t)
                        matched = True
                        break
            if matched == False:
                unmatchedTasks.append(t)

        sortedTasks = []
        for k, v in matchedTasks.iteritems():
            sortedTasks += v

        oldContent = self.to_string(indentLevel=1)
        sortedTasks += unmatchedTasks
        self.tasks = sortedTasks

        self.content = self.to_string(
            title=False, tasks=sortedTasks, indentLevel=0)

        hasProjects = False
        try:
            this = self.projects
            hasProjects = True
        except:
            pass

        if hasProjects:
            for p in self.projects:
                p.tasks = p.sort_tasks(workflowTags, 1)

        for t in self.tasks:
            t.tasks = t.sort_tasks(workflowTags, 1)

        # ADD DIRECTLY TO CONTENT IF THE PROJECT IS BEING ADDED SPECIFICALLY TO
        # THIS OBJECT
        newContent = self.to_string(
            tasks=sortedTasks, indentLevel=1)

        if self.parent:
            self.parent._update_document_tree(
                oldContent=oldContent,
                newContent=newContent
            )

        self.content = self.content.replace(self.to_string(indentLevel=0, title=False), self.to_string(
            indentLevel=0, title=False, tasks=sortedTasks))

        self.refresh
        return sortedTasks