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 6920111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:06:22+00:00 2026-05-27T10:06:22+00:00

I have a list like this: s1 d2 s1 d4 s3 d2 s4 d1

  • 0

I have a list like this:

s1   d2
s1   d4
s3   d2
s4   d1
s1   d3 
s4   d1
s5   d6
s3   d5
s1   d2
s1   d3

I need to obtain, for every element in the first column (s_) the list of element in the second column (d_) in the same order of appearance. In this case:

s1  d2 d4 d3 d2 d3
s3  d2 d5
s4  d1 d1    
s5  d6 

The order of the s_ is not important, the order of the d_ is.
Can you suggest a simple and fast approach to do it (because the list is large), maybe in awk?

  • 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-27T10:06:23+00:00Added an answer on May 27, 2026 at 10:06 am

    Something like this, perhaps (for the command line):

    awk '{ vals[$1] = vals[$1] " " $2 }; END { for (key in vals) { print key,vals[key] }}' list
    

    Formatted prettier as an awk script:

    { vals[$1] = vals[$1] " " $2 }
    END {
        for (key in vals) {
            print key,vals[key]
        }
    }
    

    What this does is store, by index of the first values, a string that contains the progressive values on the right side. So each time it finds one, it concatenates it to the end of that string. Then at the end, it prints each pair out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list like this [[x,y,1],[w,u,4],[m,n,3] ... [p,q,5]] I need to sort the
i need help, i have to read a list like this [1, 2, 3]
Suppose I have a list like this one: list= [[a,123,b],[h,435,t],[w,234,j]] What I need is
I have a list like this Dim emailList as new List(Of String) emailList.Add(one@domain.com) emailList.Add(two@domain.com)
I have a list like this: <select name=select_list_name id=list_id> <option value=>Select Option</option> <option value=value1>Option
I have a list like this: ['Ww','Aa','Bb','Cc','ww','AA','BB','CC'] And continuing in such a pattern, with
Suppose I have a list like this <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li>
may be too simple groovy question but....please help i have a list like this:
Still working on lisp recipes and idioms. I have a list like this: ((a
I have list of strings like this FirstName-Lastname (separated by a dash -) I

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.