We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Sort Paragraphs Alphabetically


how would I sort a subset of paragraphs alphabetically?

Thanks, Jamie

I’ve done it like this, is there a better way? toc is my list of original paragraphs.

        var clone = new List<Paragraph>();
        foreach (var p in toc)
        clone.Sort(delegate(Paragraph a, Paragraph b) { return a.Range.Text.CompareTo(b.Range.Text); });

        for (var i = 0; i < toc.Count; i++ )
            toc[i].ParentSection.Body.InsertAfter(clone[i], toc[i]);


Thanks for your inquiry. Could you please share some more detail about your query along with input and expected output Word documents? We will investigate the issue on our side and provide you more information. Please ZIP and attach your documents.