LINQ কোয়েরি সিনট্যাক্সে orderby ক্লজ ব্যবহার করে কালেকশন সর্ট করা যায়। ascending (ডিফল্ট) বা descending 지정 করা যায়।
উদাহরণ
using System;
using System.Collections.Generic;
using System.Linq;
class Demo {
static void Main() {
List list = new List { "iOS by Apple", "Android by Google", "Symbian by Nokia" };
var sorted = from e in list orderby e.Length descending select e;
foreach (string s in sorted) Console.WriteLine(s);
}
}
আউটপুট
Android by Google Symbian by Nokia iOS by Apple