Try this snippet:
var sortedValues = values .OrderByDescending(x => x.Length) .ThenByDescending(x => Convert.ToInt32(x));
If you really need use it as a List, then add
ToList() at the end.
I'm going to assume you actually care about the value of each integer. If so:
var sortedValues = values.OrderByDescending(x => x.Length) .ThenByDescending(x => int.Parse(x));
This will yield a deferred
int.Parse is only for the purpose of secondary ordering. If you need to materialize it,
ToList will need to be called.
values.OrderByDescending(x => x.Length).ThenByDescending(x => int.Parse(x));
Most of the answers here are written using Lambda Syntax, if you want query syntax try this. Result should be the same.
var sortedValues = from x in values orderby x.Length descending, x descending select x;
- How to use Linq to sort an array by Length and then value
- LINQ to find array indexes of a value
- Linq Where value is in Array
- C# LINQ select from where value is not contained in array / list
- linq remove item from object array where property equals value
- How to get a byte array length using LINQ to Entities?
- Linq expression to set all values of an array to a given value
- Performing a Parent then Child sort in Linq
- Linq group string array by count and sort
- sort string array using LINQ
- LINQ Source Code Available
- How do you sort a String List by the number of words matched with an Array in Linq
- Sort dictionary by value - descending THEN alphabetical C#
- Convert LINQ returned value to 2D Array
- LINQ - SelectMany OrderBy Outer Value and then Inner Value
- Is possible with LINQ to extract from an array of objects the value of one property and create a new array?
- Check if a value from one array exists in another array using linq
- creating Linq to sqlite dbml from DbLinq source code
- C# - Code supposed to be unreachable when calculate value in LINQ sum method
- C# LINQ get objects with field value that do not match a string array blacklist
- LINQ datarow string to array and then into to string list
- C# LINQ to rank time series values on a daily basis => partition by date, then rank by value (largest to smallest)
- How to get 0 out of a null linq query value when a condition isn't met and then set it to a ViewBag
- Fastest way to insert a value in int List and then sort the list
- Using Linq to Sort Students within Groups and then Rearrange Group Order
- Linq into the array then find values in the array and list to combobox
- Can't add a new record with an integer value into database by using linq from code C#
- C# linq to json how to read a property value within a Array
- Top K Numbers from Un Ordered Array Without using Sort or Linq OrderBy methods
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- C# LINQ Distinct(IEqualityComparer) help
- how to use Linq " NOT IN"
- using LINQ inside a function
- how to change the value of dictionary using linq based on key?
- Read specific element out of IEnumerable<XElement>
- LINQ select to new object, setting values of object in function
- Linq query to list VB.NET
- How can I convert this SQL Query into LINQ (OVER (PARTITION BY Date))
- Including a navigational property in a .Where()?
- Select Distinct records by IDictionary<string,object> property in an object
- Linq (EF) where clause with string comma seperated
- Dynamic linq - Group by interval (DateTime, Numeric)
- How to get group of records with latest date using Linq to Entities
- Linq Data Source WhereParameters with "\" in value
- Date Format in C# Linq
- Check if list contains element that contains a string and get that element
- How to select all objects that match all the ids in a list?
- How can I write a generic extension method for converting a delimited string to a list?
- LINQ to SQL Custom Property query on where clause
- Implement "not in" (aka "not exists") logic in LINQ