public static void Sort(Product[] products, IProductComparer comparer)
 {
     for(var i=0; i<products.Length-1; i++)
         for (var j = i + 1; j < products.Length; j++)
         {
             if (comparer.Compare(products[i], products[j]) > 0)
             {
                 var temp = products[i];
                 products[i] = products[j];
                 products[j] = temp;
             }
         }
 }
 public static void Sort(Product[] products, IProductComparer comparer)
 {
     for (var i = 0; i < products.Length - 1; i++)
     {
         for (var j = i + 1; j < products.Length; j++)
         {
             if (comparer.Compare(products[i], products[j]) > 0)
             {
                 var temp = products[i];
                 products[i] = products[j];
                 products[j] = temp;
             }
         }
     }
 }
예제 #3
0
 public void Sort(IProductComparer comparer)
 {
     for (var i = 0; i < _list.Count - 1; i++)
     {
         for (var j = i + 1; j < _list.Count; j++)
         {
             var left  = (Product)_list[i];
             var right = (Product)_list[j];
             if (comparer.Compare(left, right) > 0)
             {
                 var temp = left;
                 _list[i] = _list[j];
                 _list[j] = temp;
             }
         }
     }
 }
예제 #4
0
 public void Sort(IProductComparer comparer)
 {
     for (var i = 0; i < Count - 1; i++)
     {
         for (var j = i + 1; j < Count; j++)
         {
             var leftProduct  = (Product)list[i];
             var rightProduct = (Product)list[j];
             if (comparer.Compare(leftProduct, rightProduct) > 0)
             {
                 var temp = leftProduct;
                 list[i] = list[j];
                 list[j] = temp;
             }
         }
     }
 }