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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:50:04+00:00 2026-05-14T01:50:04+00:00

My OM has a ‘product’ object. Each product has a ‘manufacturer id’ (property, integer).

  • 0

My OM has a ‘product’ object.
Each product has a ‘manufacturer id’ (property, integer).
When I have a list of products to display, the first three are displayed as the ‘featured products’.
The list is already sorted in a specific sort order, putting the ‘featured’ products first in the list.

However, I now need to ensure the featured products in the listing are from different Manufacturers. I want to have a method to call to do this re-sorting. Trying to utilize LINQ to to the querying of the input ‘products’ and the ‘results’

public List<Product> SetFeatures(List<Product> products, int numberOfFeatures)
{
    List<Product> result;

    // ensure the 2nd product is different manufacturer than the first ....

    // ensure the 3rd product is a different manufacturer than the first two... 

    // ... etc ... for the numberOfFeatures

    return result;

}

Thanks in advance.

Clarification:
The original list is in a specific order: the ‘best selling’, highest first (descending order). The resulting list should remain in this order with the exception of adjusting or moving ‘up’ items so that the differing manufacturers are seen the top n features.

If the first n (numberOfFeatures) of items all have different manufacturers, then the listing does not need to be altered at all.
e.g. If numberOfFeatures = 3
Product 1 – Manufacturer A (1st feature)
Product 2 – Manufacturer B (2nd feature)
Product 3 – Manufacturer C (3rd feature)
Product 4 – Manufacturer A (…not checked…)
Product 5 – Manufacturer A (…not checked…)

e.g. Case to adjust … for example …
INPUT List
Product 1 – Manufacturer A
Product 2 – Manufacturer A
Product 3 – Manufacturer B
Product 4 – Manufacturer A
Product 5 – Manufacturer F
(… we would want …)
Product 1 – Manufacturer A (1st feature)
Product 3 – Manufacturer B (2nd feature … moved up)
Product 5 – Manufacturer F (3rd feature … moved up)
Product 2 – Manufacturer A (…pushed down the list…)
Product 4 – Manufacturer A (…pushed down the list…)

  • 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-14T01:50:05+00:00Added an answer on May 14, 2026 at 1:50 am

    I think Bryan encapsulated the sorting logic pretty well and it’s not something I thought of doing. I’d like to present my take on it anyway using a Foo example.

            List<Foo> foos = new List<Foo>()
        {
            new Foo() { Baz = 1, Blah = "A"},
            new Foo() { Baz = 2, Blah = "A"},
            new Foo() { Baz = 3, Blah = "B"},
            new Foo() { Baz = 4, Blah = "B"},
            new Foo() { Baz = 5, Blah = "B"},
            new Foo() { Baz = 6, Blah = "C"},
            new Foo() { Baz = 7, Blah = "C"},
            new Foo() { Baz = 8, Blah = "D"},
            new Foo() { Baz = 9, Blah = "A"},
            new Foo() { Baz = 10, Blah = "B"},
        };
    
        var query = foos.Distinct(new FooComparer()).Take(3).ToList();
        var theRest = foos.Except(query);
    
        query.AddRange(theRest);
    

    FooComparer being

        public class FooComparer : IEqualityComparer<Foo>
    {
        public bool Equals(Foo x, Foo y)
        {
            return x.Blah == y.Blah;
        }
    
        public int GetHashCode(Foo obj)
        {
            return obj.Blah.GetHashCode();
        }
    }
    

    You get (Baz) 1, 3, and 6 shifted to top, the remaining in their original order afterwards.

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

Sidebar

Related Questions

has anyone an idea why I have the following problem with passing locals to
Has anyone used Commission Junction's Product Catalog Search API for searching/fetching local deals? (BuyWithMe
Has anyone done a proper benchmark on the difference in performance between these three
Has anyone else tried using SimpleModal in IE9? If so, have you experienced that
Has anyone managed to bind a DataNavigator and a DataGrid using the DataSource property
Has anyone had any success getting StreetView to display in a TWebBrowser control? I
Has anyone made an online shop that uses php/mysql to instantly deliver a product
Has anyone ever used the hidden class PackageParser in Android source code with java
Has anyone successfully tried minifying AND concatenating all the jqGrid locale files so that
Has anyone used Hazelcast (preferably 2.1) with play framework 2.0/2.1 (not 1.2+)? I am

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.