Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Sorting text

    Help wanted · · · – – – · · ·
    2
    2
    56
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Lakshman Ragde
      Lakshman Ragde last edited by

      I have a file that contains a large number of song lyrics. Each lyric has the song title followed by a blank line, then by the all the words of the lyric. The next lyric starts after 4 blank lines, the next after another 4 lines and so on. Is there a way to sort these lyrics (by the song titles) alphabetically? Thanks for any help.

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @Lakshman Ragde last edited by

        @lakshman-ragde ,

        Your problem seems more of a database manipulation than text editor.

        Sorting chunks (groups of lines) rather than single lines will take more effort on your part.

        If you absolutely must use a text editor, then I would suggest crafting a regex that joins the n lines of your chunk with some character not in your data (😀 is my typical choice); making sure that during your join , you order things so that the sorting key is the first entry on the line. Once joined, then do the sort. After sorting, use another regex to split on 😀, and reorder if necessary.

        Before handing you a regex that might meet your needs, I would need you to supply example data… Otherwise, I’ll waste everyone’s time guessing what your data looks like, and missing some subtlety that I misunderstood. See the FAQ for a template for search/replace questions, linked below, to make sure your example data is formatted correctly.

        ----

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • FAQ: Where to find regular expressions (regex) documentation
        • Notepad++ Online User Manual: Searching/Regex
        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors