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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:25:19+00:00 2026-06-19T00:25:19+00:00

Given, for instance: var a = new List<int>(){ 1 , 2 , 50 };

  • 0

Given, for instance:

var a = new List<int>(){ 1 , 2 , 50 };
var b = new List<int>(){ 9 , 7 , 2 };

I need to merge them together to one sorted list, while adding some data indicating their origin (a or b). An output for example would be something like:

mergedList = { {1,false},{2,false},{2,true},{7,true},{9,true},{50,false} }

(true means it comes from a).

Edit start…

mergedList =
{ {1,IsB=false},{2,IsB=false},{2,IsB=true},{7,IsB=true},{9,IsB=true},{50,IsB=false} }

…Edit end

How can I do it with LINQ, preferably in query statement form (from ... select ...) ?

  • 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-06-19T00:25:21+00:00Added an answer on June 19, 2026 at 12:25 am
    var aItems = from aa in a
                 select new {Value = aa, Indicator = true};
    var bItems = from bb in b
                 select new {Value = bb, Indicator = false};
    
    var result = aItems.Concat(bItems).OrderBy(t => t.Value);
    

    And pure method syntax:

    var aItems = a.Select(aa => new {Value = aa, Indicator = true});
    var bItems = b.Select(bb => new {Value = bb, Indicator = false});
    var result = aItems.Concat(bItems).OrderBy(t => t.Value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to test, if an instance is exactly of a given type. But
Given some EventEmitter instance in Node.js , is it absolutely guaranteed that all events
say your given an instance of List[Class[_ <: Base]] , and say that many
That's the question xD Given an instance of a CCSprite in cocos2d in iphone,
I have a django application using multiple databases. Given an instance of a model,
Given an XDocument instance, how can I easily get a TextReader that represents that
1) If we want to create an instance of a given type during runtime
Given: var memberships = context.Memberships.OrderBy(it.CreateDate).ToList(); var monthlyCounts = from m in memberships where m.CreateDate
Given an instance of a class that derives from System.Web.Page (ie. a normal page
Given a string classname , I want to dynamically create a new JavaScript function

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.