<?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%2FCollections_Data_Structure%2FSort</id>
		<title>Csharp/C Sharp/Collections Data Structure/Sort - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FCollections_Data_Structure%2FSort"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Sort&amp;action=history"/>
		<updated>2026-04-29T17:15:43Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Sort&amp;diff=654&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/Collections_Data_Structure/Sort&amp;diff=654&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/Collections_Data_Structure/Sort&amp;diff=655&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Collections_Data_Structure/Sort&amp;diff=655&amp;oldid=prev"/>
				<updated>2010-05-26T11:39:21Z</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;==A simple version of the Quicksort==&lt;br /&gt;
&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;
C# A Beginner&amp;quot;s Guide&lt;br /&gt;
By Schildt&lt;br /&gt;
Publisher: Osborne McGraw-Hill&lt;br /&gt;
ISBN: 0072133295&lt;br /&gt;
*/&lt;br /&gt;
// A simple version of the Quicksort. &lt;br /&gt;
 &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
class Quicksort { &lt;br /&gt;
 &lt;br /&gt;
  // Set up a call to the actual Quicksort method. &lt;br /&gt;
  public static void qsort(char[] items) { &lt;br /&gt;
    qs(items, 0, items.Length-1); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // A recursive version of Quicksort for characters. &lt;br /&gt;
  static void qs(char[] items, int left, int right)  &lt;br /&gt;
  {  &lt;br /&gt;
    int i, j;  &lt;br /&gt;
    char x, y;  &lt;br /&gt;
  &lt;br /&gt;
    i = left; j = right;  &lt;br /&gt;
    x = items[(left+right)/2];  &lt;br /&gt;
  &lt;br /&gt;
    do {  &lt;br /&gt;
      while((items[i] &amp;lt; x) &amp;amp;&amp;amp; (i &amp;lt; right)) i++;  &lt;br /&gt;
      while((x &amp;lt; items[j]) &amp;amp;&amp;amp; (j &amp;gt; left)) j--;  &lt;br /&gt;
  &lt;br /&gt;
      if(i &amp;lt;= j) {  &lt;br /&gt;
        y = items[i];  &lt;br /&gt;
        items[i] = items[j];  &lt;br /&gt;
        items[j] = y;  &lt;br /&gt;
        i++; j--;  &lt;br /&gt;
      }  &lt;br /&gt;
    } while(i &amp;lt;= j);  &lt;br /&gt;
  &lt;br /&gt;
    if(left &amp;lt; j) qs(items, left, j);  &lt;br /&gt;
    if(i &amp;lt; right) qs(items, i, right);  &lt;br /&gt;
  } &lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
public class QSDemo { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    char[] a = { &amp;quot;d&amp;quot;, &amp;quot;x&amp;quot;, &amp;quot;a&amp;quot;, &amp;quot;r&amp;quot;, &amp;quot;p&amp;quot;, &amp;quot;j&amp;quot;, &amp;quot;i&amp;quot; }; &lt;br /&gt;
    int i; &lt;br /&gt;
 &lt;br /&gt;
    Console.Write(&amp;quot;Original array: &amp;quot;); &lt;br /&gt;
    for(i=0; i &amp;lt; a.Length; i++)  &lt;br /&gt;
      Console.Write(a[i]); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
    // now, sort the array &lt;br /&gt;
    Quicksort.qsort(a); &lt;br /&gt;
     &lt;br /&gt;
    Console.Write(&amp;quot;Sorted array: &amp;quot;); &lt;br /&gt;
    for(i=0; i &amp;lt; a.Length; i++)  &lt;br /&gt;
      Console.Write(a[i]); &lt;br /&gt;
  } &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;
==Bubble sort==&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;
&lt;br /&gt;
  delegate bool Comparator(object lhs, object rhs);&lt;br /&gt;
  class MainEntryPoint {&lt;br /&gt;
    static void Main() {&lt;br /&gt;
      Employee [] employees = {&lt;br /&gt;
              new Employee(&amp;quot;A&amp;quot;, 20000),&lt;br /&gt;
              new Employee(&amp;quot;B&amp;quot;, 10000),&lt;br /&gt;
              new Employee(&amp;quot;C&amp;quot;, 25000),&lt;br /&gt;
              new Employee(&amp;quot;D&amp;quot;, 99999),&lt;br /&gt;
              new Employee(&amp;quot;E&amp;quot;, 23000),&lt;br /&gt;
              new Employee(&amp;quot;F&amp;quot;, 50000)};&lt;br /&gt;
              &lt;br /&gt;
      BubbleSorter.Sort(employees, new Comparator(Employee.IsGreater));&lt;br /&gt;
      for (int i=0 ; i&amp;lt;employees.Length ; i++){&lt;br /&gt;
        Console.WriteLine(employees[i].ToString());&lt;br /&gt;
      }  &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  class Employee {&lt;br /&gt;
    private string name;&lt;br /&gt;
    private decimal salary;&lt;br /&gt;
    public Employee(string name, decimal salary)&lt;br /&gt;
    {&lt;br /&gt;
      this.name = name;&lt;br /&gt;
      this.salary = salary;&lt;br /&gt;
    }&lt;br /&gt;
    public override string ToString()&lt;br /&gt;
    {&lt;br /&gt;
      return string.Format(name + &amp;quot;, {0:C}&amp;quot;, salary);&lt;br /&gt;
    }&lt;br /&gt;
    public static bool IsGreater(object a, object b)&lt;br /&gt;
    {&lt;br /&gt;
      Employee empA = (Employee) a;&lt;br /&gt;
      Employee empB = (Employee) b;&lt;br /&gt;
      return (empA.salary &amp;gt; empB.salary) ? true : false;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  class BubbleSorter&lt;br /&gt;
  {&lt;br /&gt;
    static public void Sort(object [] sortArray, Comparator gtMethod) {&lt;br /&gt;
      for (int i=0 ; i&amp;lt;sortArray.Length ; i++) {&lt;br /&gt;
        for (int j=i+1 ; j&amp;lt;sortArray.Length ; j++) {&lt;br /&gt;
          if (gtMethod(sortArray[j], sortArray[i])) {&lt;br /&gt;
            object temp = sortArray[i];&lt;br /&gt;
            sortArray[i] = sortArray[j];&lt;br /&gt;
            sortArray[j] = temp;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&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;
==Demonstrate the Bubble sort==&lt;br /&gt;
&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;
C# A Beginner&amp;quot;s Guide&lt;br /&gt;
By Schildt&lt;br /&gt;
Publisher: Osborne McGraw-Hill&lt;br /&gt;
ISBN: 0072133295&lt;br /&gt;
*/&lt;br /&gt;
/* &lt;br /&gt;
   Project 5-1 &lt;br /&gt;
   Demonstrate the Bubble sort. &lt;br /&gt;
*/ &lt;br /&gt;
using System; &lt;br /&gt;
 &lt;br /&gt;
public class BubbleSort {  &lt;br /&gt;
  public static void Main() {  &lt;br /&gt;
    int[] nums = { 99, -10, 100123, 18, -978, &lt;br /&gt;
                   5623, 463, -9, 287, 49 }; &lt;br /&gt;
    int a, b, t;  &lt;br /&gt;
    int size;  &lt;br /&gt;
  &lt;br /&gt;
    size = 10; // number of elements to sort  &lt;br /&gt;
  &lt;br /&gt;
    // display original array  &lt;br /&gt;
    Console.Write(&amp;quot;Original array is:&amp;quot;); &lt;br /&gt;
    for(int i=0; i &amp;lt; size; i++) &lt;br /&gt;
      Console.Write(&amp;quot; &amp;quot; + nums[i]);  &lt;br /&gt;
    Console.WriteLine();  &lt;br /&gt;
  &lt;br /&gt;
    // This is the bubble sort.  &lt;br /&gt;
    for(a=1; a &amp;lt; size; a++)  &lt;br /&gt;
      for(b=size-1; b &amp;gt;= a; b--) {  &lt;br /&gt;
        if(nums[b-1] &amp;gt; nums[b]) { // if out of order  &lt;br /&gt;
          // exchange elements   &lt;br /&gt;
          t = nums[b-1];  &lt;br /&gt;
          nums[b-1] = nums[b];  &lt;br /&gt;
          nums[b] = t;  &lt;br /&gt;
        }  &lt;br /&gt;
      }  &lt;br /&gt;
  &lt;br /&gt;
    // display sorted array  &lt;br /&gt;
    Console.Write(&amp;quot;Sorted array is:&amp;quot;);  &lt;br /&gt;
    for(int i=0; i &amp;lt; size; i++) &lt;br /&gt;
      Console.Write(&amp;quot; &amp;quot; + nums[i]);  &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  } &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;
==Implements the recursive merge sort algorithm to sort an array==&lt;br /&gt;
&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;
public class MergeSort {&lt;br /&gt;
  public static void Sort (int[] data, int left, int right) {&lt;br /&gt;
    if (left &amp;lt; right) {&lt;br /&gt;
      int middle = (left + right)/2;&lt;br /&gt;
      Sort(data, left, middle);&lt;br /&gt;
      Sort(data, middle + 1, right);&lt;br /&gt;
      Merge(data,left, middle, middle+1, right);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void Merge(int[] data, int left, int middle, int middle1, int right) {&lt;br /&gt;
    int oldPosition = left;&lt;br /&gt;
    int size = right - left + 1;&lt;br /&gt;
    int[] temp = new int[size];&lt;br /&gt;
    int i = 0;  &lt;br /&gt;
    &lt;br /&gt;
    while (left &amp;lt;= middle &amp;amp;&amp;amp; middle1 &amp;lt;= right) {&lt;br /&gt;
      if (data[left] &amp;lt;= data[middle1]) &lt;br /&gt;
        temp[i++] = data[left++];&lt;br /&gt;
      else&lt;br /&gt;
        temp[i++] = data[middle1++];&lt;br /&gt;
    }&lt;br /&gt;
    if (left &amp;gt; middle) &lt;br /&gt;
      for (int j = middle1; j &amp;lt;= right; j++)&lt;br /&gt;
        temp[i++] = data[middle1++];&lt;br /&gt;
    else&lt;br /&gt;
      for (int j = left; j &amp;lt;= middle; j++)&lt;br /&gt;
        temp[i++] = data[left++];&lt;br /&gt;
    Array.Copy(temp, 0, data, oldPosition, size);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  public static void Main (String[] args) {&lt;br /&gt;
    int[] data = new int[]{2,3,1,6,2,98,4,6,4,3,45};&lt;br /&gt;
    &lt;br /&gt;
    for (int i = 0; i &amp;lt; data.Length; i++) { &lt;br /&gt;
      Console.WriteLine(data[i]);&lt;br /&gt;
    }&lt;br /&gt;
    Sort(data, 0, data.Length-1);&lt;br /&gt;
    for (int i = 0; i &amp;lt; data.Length; i++) { &lt;br /&gt;
      Console.WriteLine(data[i]);&lt;br /&gt;
    }&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;
==Sorts an array of data using the insertion sort algorithm==&lt;br /&gt;
&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;
public class InsertionSort {&lt;br /&gt;
    &lt;br /&gt;
  public static void InsertNext(int i, int[] item) {&lt;br /&gt;
    int current = item[i];&lt;br /&gt;
    int j = 0;&lt;br /&gt;
    while (current &amp;gt; item[j]) j++;&lt;br /&gt;
    for (int k = i; k &amp;gt; j; k--)&lt;br /&gt;
      item[k] = item[k-1];&lt;br /&gt;
    item[j] = current;&lt;br /&gt;
  }&lt;br /&gt;
  public static void Sort(int[] item) {&lt;br /&gt;
    for (int i = 1; i &amp;lt; item.Length; i++) {&lt;br /&gt;
      InsertNext(i, item); &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public static void Main()  {&lt;br /&gt;
    int[] item = new int[]{2,4,1,6,3,8,1,0,2,6,3,6};&lt;br /&gt;
    Sort(item);&lt;br /&gt;
    for(int i=0; i&amp;lt;item.Length;i++){&lt;br /&gt;
        Console.WriteLine(item[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&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>