<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FOrderBy</id>
		<title>Csharp/C Sharp/LINQ/OrderBy - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FLINQ%2FOrderBy"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/OrderBy&amp;action=history"/>
		<updated>2026-04-29T18:03:39Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/OrderBy&amp;diff=482&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/OrderBy&amp;diff=482&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/OrderBy&amp;diff=483&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/LINQ/OrderBy&amp;diff=483&amp;oldid=prev"/>
				<updated>2010-05-26T11:38:40Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==an array of string values sorted first by length, then sorted alphabetically, using a case-insentive comparison.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CaseInsensitiveComparer : IComparer&amp;lt;string&amp;gt; {&lt;br /&gt;
    public int Compare(string x, string y) {&lt;br /&gt;
        return string.rupare(x, y, true);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;a&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;c&amp;quot; };&lt;br /&gt;
        var sortedWords =&lt;br /&gt;
            words.OrderBy(a =&amp;gt; a.Length)&lt;br /&gt;
                    .ThenBy(a =&amp;gt; a, new CaseInsensitiveComparer());&lt;br /&gt;
        Console.Write(sortedWords);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==First OrderBy Prototype==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] presidents = {&amp;quot;ant&amp;quot;, &amp;quot;arding&amp;quot;, &amp;quot;arrison&amp;quot;, &amp;quot;eyes&amp;quot;, &amp;quot;over&amp;quot;, &amp;quot;ackson&amp;quot;};&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; items = presidents.OrderBy(s =&amp;gt; s.Length);&lt;br /&gt;
        foreach (string item in items)&lt;br /&gt;
            Console.WriteLine(item);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==OrderBy: prints an alphabetically sorted version of a string array==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;C&amp;quot;, &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot; };&lt;br /&gt;
        var sortedWords =&lt;br /&gt;
            from w in words&lt;br /&gt;
            orderby w&lt;br /&gt;
            select w;&lt;br /&gt;
        Console.WriteLine(&amp;quot;The sorted list of words:&amp;quot;);&lt;br /&gt;
        foreach (var w in sortedWords) {&lt;br /&gt;
            Console.WriteLine(w);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==OrderBy with customized Comparer==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CaseInsensitiveComparer : IComparer&amp;lt;string&amp;gt; {&lt;br /&gt;
    public int Compare(string x, string y) {&lt;br /&gt;
        return string.rupare(x, y, true);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;a&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;c&amp;quot; };&lt;br /&gt;
        var sortedWords = words.OrderBy(a =&amp;gt; a, new CaseInsensitiveComparer());&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==OrderBy with passing a lambda function==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CaseInsensitiveComparer : IComparer&amp;lt;string&amp;gt; {&lt;br /&gt;
    public int Compare(string x, string y) {&lt;br /&gt;
        return string.rupare(x, y, true);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;a&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;c&amp;quot; };&lt;br /&gt;
        var sortedWords = words.OrderBy(a =&amp;gt; a, new CaseInsensitiveComparer());&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==products sorted alphabetically by the product name==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; products = GetProductList();&lt;br /&gt;
        var sortedProducts =&lt;br /&gt;
            from p in products&lt;br /&gt;
            orderby p.ProductName&lt;br /&gt;
            select p;&lt;br /&gt;
        Console.WriteLine(sortedProducts);&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Product&amp;gt; GetProductList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        return empTree;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==products sorted by the number of units of each product that are in stock==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; products = GetProductList();&lt;br /&gt;
        var sortedProducts =&lt;br /&gt;
            from p in products&lt;br /&gt;
            orderby p.UnitsInStock descending&lt;br /&gt;
            select p;&lt;br /&gt;
        Console.Write(sortedProducts);&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Product&amp;gt; GetProductList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        return empTree;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==sorted alphabetically in descending order, using a case insensitive comparision.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CaseInsensitiveComparer : IComparer&amp;lt;string&amp;gt; {&lt;br /&gt;
    public int Compare(string x, string y) {&lt;br /&gt;
        return string.rupare(x, y, true);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;a&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;c&amp;quot; };&lt;br /&gt;
        var sortedWords = words.OrderByDescending(a =&amp;gt; a, new CaseInsensitiveComparer());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==string array sorted by the length each element==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] words = { &amp;quot;abc&amp;quot;, &amp;quot;bcd&amp;quot;, &amp;quot;def&amp;quot; };&lt;br /&gt;
        var sortedWords =&lt;br /&gt;
            from w in words&lt;br /&gt;
            orderby w.Length&lt;br /&gt;
            select w;&lt;br /&gt;
        Console.WriteLine(&amp;quot;The sorted list of words (by length):&amp;quot;);&lt;br /&gt;
        foreach (var w in sortedWords) {&lt;br /&gt;
            Console.WriteLine(w);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==uses a compound orderby to sort a list of digits first by length of their name, and then alphabetically.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] digits = { &amp;quot;zero&amp;quot;, &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;};&lt;br /&gt;
        var sortedDigits =&lt;br /&gt;
            from d in digits&lt;br /&gt;
            orderby d.Length, d&lt;br /&gt;
            select d;&lt;br /&gt;
        Console.WriteLine(&amp;quot;Sorted digits:&amp;quot;);&lt;br /&gt;
        foreach (var d in sortedDigits) {&lt;br /&gt;
            Console.WriteLine(d);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==uses a compound orderby to sort a list of products, first by category, and then by unit price, from highest to lowest.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; products = GetProductList();&lt;br /&gt;
        var sortedProducts =&lt;br /&gt;
            from p in products&lt;br /&gt;
            orderby p.Category, p.UnitPrice descending select p;&lt;br /&gt;
        foreach (var s in sortedProducts) {&lt;br /&gt;
            Console.Write(s);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    static List&amp;lt;Product&amp;gt; GetProductList() {&lt;br /&gt;
        List&amp;lt;Product&amp;gt; empTree = new List&amp;lt;Product&amp;gt;();&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;A&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 12, UnitsInStock = 5, Total = 36, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;B&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 2, UnitsInStock = 4, Total = 35, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;C&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 3, Total = 34, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;D&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 112, UnitsInStock = 0, Total = 33, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;E&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 1112, UnitsInStock = 2, Total = 32, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        empTree.Add(new Product { ProductName = &amp;quot;F&amp;quot;, Category = &amp;quot;O&amp;quot;, UnitPrice = 11112, UnitsInStock = 0, Total = 31, OrderDate = new DateTime(2005, 1, 1), Id = 1 });&lt;br /&gt;
        return empTree;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Product : IComparable&amp;lt;Product&amp;gt; {&lt;br /&gt;
    public string ProductName { get; set; }&lt;br /&gt;
    public string Category { get; set; }&lt;br /&gt;
    public int UnitPrice { get; set; }&lt;br /&gt;
    public int UnitsInStock { get; set; }&lt;br /&gt;
    public int Total { get; set; }&lt;br /&gt;
    public DateTime OrderDate { get; set; }&lt;br /&gt;
    public int Id { get; set; }&lt;br /&gt;
    public override string ToString() {&lt;br /&gt;
        return String.Format(&amp;quot;Id: {0}, Name: {1} , Category: {3}&amp;quot;, this.Id, this.ProductName, this.Category);&lt;br /&gt;
    }&lt;br /&gt;
    int IComparable&amp;lt;Product&amp;gt;.rupareTo(Product other) {&lt;br /&gt;
        if (other == null)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;gt; other.Id)&lt;br /&gt;
            return 1;&lt;br /&gt;
        if (this.Id &amp;lt; other.Id)&lt;br /&gt;
            return -1;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Where with OrderBy==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        string[] names = { &amp;quot;J&amp;quot;, &amp;quot;P&amp;quot;, &amp;quot;G&amp;quot;, &amp;quot;Pa&amp;quot; };&lt;br /&gt;
        IEnumerable&amp;lt;string&amp;gt; query = names.Where(n =&amp;gt; n.Contains(&amp;quot;a&amp;quot;))&lt;br /&gt;
                                         .OrderBy(n =&amp;gt; n.Length)&lt;br /&gt;
                                         .Select(n =&amp;gt; n.ToUpper());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>