score:2
if there is no common sub-class among these element types, you can use linq to project the lists using a generic tuple<int, int, object>
(i.e. rating, vote, and the original element instance) containing the two properties you are interested in. then you can do a simple query to pick the top 10 elements:
list<a> ax = /* ... */;
list<b> bx = /* ... */;
list<c> cx = /* ... */;
/* ... */
ienumerable<tuple<int, int, object>> ratingsandvotes =
ax.select((a) => tuple.create(a.rating, a.vote, a)).concat(
bx.select((b) => tuple.create(b.rating, b.vote, b)).concat(
cx.select((c) => tuple.create(c.rating, c.vote, c)) /* ... */;
tuple<int, int, object>[] toptenitems =
ratingsandvotes.orderbydescending((i) => i.item1).thenbydescending((i) => i.item2).take(10).toarray();
// toptenitems now contains the top 10 items out of all the lists;
// for each tuple element, item1 = rating, item2 = vote,
// item3 = original list item (as object)
score:1
you can use orderby and thenby to order by two (or more) fields and then use take to get the top 10:
var mylist = new list<film>();
// ... populate list with some stuff
var top10 = mylist.orderby(f => f.rating).thenby(f => f.vote).take(10);
hope that helps :)
score:3
you can start with something like:
var res = l1.concat(l2).concat(l3).concat(l4).concat(l5)
.orderbydescending(k => k.rating)
.thenby(k=>k.vote)
.take(10).tolist();
where l1...l5 are your lists
score:8
try something like below
var topten = yourlist.orderby(x => x.rating).thenby(z => z.vote).take(10)
Source: stackoverflow.com
Related Query
- Find object inside collection of List
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Find all items whose collection property contains items in another list
- How can I find object in List with Linq?
- LINQ to EF - Find records where string property of a child collection at least partially matches all records in a list of strings
- how to find minimum difference object of collection in c# linq
- Find rows where child collection contains all elements of the list
- List Inside IQueryable Object
- How to find how many times the same object appears in a list and then find a property of the most appeared object
- Using Linq find first object in list sorting by property A, then property B
- LINQ: single list which consists of multiple properties of same type of object collection
- find item inside list of list
- find object from Tree or List Hierarchy
- Find the List index of the object containing the closest property value
- How to find the peak 3D coordinate inside a list of 3D coordinates using LINQ?
- Find an Object that contains a string in a list of strings using LINQ
- LINQ returns arrays, not a collection of list object
- get property value from object collection list
- Find object in list with given property value then find dictionary value
- LINQ Search in collection of object containing object which contains list
- Given a list of color objects, find the most/least frequently existing color, and return that as a color object
- Using find method of the list collection
- Find an object within a list and replace its value
- linq find in which position is my object in List
- Converting Generic List of object to defined collection class with Lambda and C#
- Find distinct values from a list of object by one field only
- Combine contents of list member of object collection into single list with linq
- Use LINQ to find value inside a nested collection
- C# LINQ - Find object in list between two properties
- Xml parse object inside of list of objects inside object using LINQ
More Query from same tag
- Filter tree list retaining parent using LINQ
- LINQ syntax for SQL query with multiple inner joins and aliases
- Linq query to orderby level then parent and child item
- Group dictionary to other dictionary via intermediate map
- MongoDb c# driver LINQ vs Native query
- Using "where": Cannot convert lambda expression to type 'bool'
- Linq Lookup dynamic list
- Optimization of LookUp like LINQ Query
- Performance penalty for accessing properties in base class (C#)
- c# Dictionary of group perfomance
- Convert String to Int in EF 4.0
- Using AddRange with Distinct() is not working with Enum
- How to call a function or property in a LINQ Query Provider (ExpressionVisitor)
- Filtering out the data for Extended Trading Hours in C#
- How do I return the column names of a LINQ entity
- Need to debug LINQ simple queries in Visual Studio 2010
- LINQ: How to Append List of Elements Into Another List
- How to Filter Inner Collection using LINQ C#
- LINQ Lambda Summing NULL
- linq goup by day
- Search based on a set of keywords
- How to Translate this LINQ Query to use Lambda Expressions Instead?
- LINQ Statement with where clause makes the execution slow
- Split One Row into many based on splitting string in multiple cells
- Default groups for GroupBy linq method
- How to group by all employees with same manager in a list using c#?
- Could table-returning select Oracle query from stored procedure be transformed into LINQ?
- How to cast a Linq Dynamic Query result as a custom class?
- Error in LINQ Left JOIN
- Find items with same property from list and pick the cheaper of the two items