I want to sort the below values in C#.
any one have sample c# code?
For the case of an array, you can try Array.Sort(myArr, new AlphanumComparatorFast()) - https://www.w3schools.com/cs/cs_arrays_sort.php
If you're not using an array, please clarify the type of collection you're using.
Currently, I'm doing the below sorting condition.
But I'm not able to getting as expected sorting. It's coming like this.
Instead of this sorting, I want a piece number like this.
So you're using a datatable. Have you tried using LINQ for sorting by chance? If this data is coming from a SQL query, could you try sorting on the query itself?
Don't forget to add the using statements:
using System.Collections.Generic;
using System.Linq;
stackoverflow.com/.../how-to-sort-datatable-by-two-columns-in-c-sharp
<span class="hljs-keyword">var newDataTable = yourtable.AsEnumerable() .OrderBy(r=> r.Field<<span class="hljs-built_in">int>(<span class="hljs-string">"ItemIndex")) .ThenBy(r=> r.Field<<span class="hljs-built_in">int>(<span class="hljs-string">"ItemValue")) .CopyToDataTable();