Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:29:17+00:00 2026-05-27T20:29:17+00:00

How can I can sort based on a key word? I have a kind-of

  • 0

How can I can sort based on a key word? I have a kind-of complicated list and am wondering if I can sort it. Here is an example:

enter code here Room Name: RM145 
                ,ID,user Name
                ,300,NOS
                ,100,NOT
                Room Name: RM370 
                ,ID,user Name
                ,300,NOS
                Room Name: RM471  
                ,ID,user Name
                ,300,POS
                ,100,NOT
                Room Name: RM349  
                ,ID,user Name
                ,301,NOS
                ,100,NOT
                ,500,COS

My objective is to sort this list based on “Room Name“.

I have the file in both plain text and CSV. I don’t know which one is will be easier to sort. Does anyone have suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:29:18+00:00Added an answer on May 27, 2026 at 8:29 pm

    With GNU awk 4:

    awk 'END {
      PROCINFO["sorted_in"] = "@ind_num_asc"
      for (R in r)
        print r[R]
      }
    /Room Name:/ {
      rn = substr($NF, 3)
      }
    {
      r[rn] = r[rn] ? r[rn] ORS $0 : $0
      }' infile   
    

    This one should work with older GNU awk versions:

    WHINY_USERS=  awk 'END {
      for (R in r)
        print r[R]
      }
    /Room Name:/ {
      rn = sprintf("%15s", substr($NF, 3))
      }
    {
      r[rn] = r[rn] ? r[rn] ORS $0 : $0
      }' infile  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can you sort the following word by the given rule? Example data is
How can I sort an array based on a key's value occurrence and then
I have a list of fields which a user can sort using jquery. I
How can I sort an array based on two specific values within the array?
I can sort by key or value, but I need it sorted by value,
Can I sort a list of objects by a property of an associated object?
Can SQLite sort naturally? For example, CREATE TABLE animals ( id INTEGER NOT NULL
How can I sort this array by the value of the "order" key? Even
I have a key => value table I'd like to sort in Lua. The
I want to sort the tree map based on the key where key is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.