#### Re: What algorithms of sorting of an array of the big length advise?

Hello, Khimik, you wrote: K> Hello, RussianFellow, you wrote: K> I and did not master independently to write algorithm of quick sort, I use simple algorithm of search: two nested loops, the first I from 1 to N-1, the second J from I+1 to N, is in the second cycle the least number and it changes with the number which is under an index I. Such algorithm not the fastest, but at me never arose tasks for which speed would be critical. If at you an array from 10 thousand numbers, sorting by this algorithm occupies time millisecond, it is possible not to worry. It also is  sorting of an array with a title - bubble sort or bubble sort.

#### Re: What algorithms of sorting of an array of the big length advise?

I wrote for myself quick sort procedure. Like all works normally. Estimate, how much clear the code turned out: type TDoubleWithPointer=record val:double; point:pointer; end; procedure TDoubleWithPointerArray. QSort; var arr1, arr2:array of TDoubleWithPointer; i:integer; procedure DoQSort (intervalbeg, intervallast:integer); var curcount:integer; sumval:double; aveval:double; ii:integer; curvalscount:integer; lowvalscount:integer; begin curcount: = intervallast-intervalbeg+1; if curcount <=1 then exit;//Only one element, it is not necessary to sort//we Find mean value in our interval: sumval: = 0; for ii: = intervalbeg to intervallast do sumval: = sumval+arr1 [ii].val; aveval: = sumval/curcount;//we Place elements, big aveval, in the first part arr2: curvalscount: = 0; for ii: = intervalbeg to intervallast do if arr1 [ii].val> aveval then begin inc (curvalscount); arr2 [intervalbeg+curvalscount-1]: =arr1 [ii]; end; lowvalscount: = curvalscount;//we Place elements, smaller or equal aveval, in the second part arr2: for ii: = intervalbeg to intervallast do if not (arr1 [ii].val> aveval) then begin inc (curvalscount); arr2 [intervalbeg+curvalscount-1]: =arr1 [ii]; end;//It is moved arr2 in arr1: for ii: = intervalbeg to intervallast do arr1 [ii]: =arr2 [ii]; if (lowvalscount=0) or (lowvalscount=curcount) then exit;//All elements are equal in an interval, it is impossible to sort doqsort (intervalbeg, intervalbeg+lowvalscount-1); doqsort (intervalbeg+lowvalscount, intervallast); end; begin setlength (arr1, fcount); setlength (arr2, fcount); for i: = 0 to fcount-1 do arr1 [i]: =GetValue (i); doqsort (0, fcount-1); for i: = 0 to fcount-1 do SetValue (i, arr1 [i]); setlength (arr1,0); setlength (arr2,0); end;

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, Kernan, you wrote: K> Hello, Khimik, you wrote: K>> Hello, RussianFellow, you wrote: K>> I and did not master independently to write algorithm of quick sort, I use simple algorithm of search: two nested loops, the first I from 1 to N-1, the second J from I+1 to N, is in the second cycle the least number and it changes with the number which is under an index I. Such algorithm not the fastest, but at me never arose tasks for which speed would be critical. If at you an array from 10 thousand numbers, sorting by this algorithm occupies time millisecond, it is possible not to worry. K> it also is  sorting of an array with a title - bubble sort or bubble sort. At  sortings are compared the elements lying nearby, and there should be the Boolean variable, whether defining there were changes in the last iteration. In my algorithm of it is not present. And I like was mistaken a few - the second cycle should be launched from I to N, instead of from I+1 to N.

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, RussianFellow, you wrote: RF> There is an algorithm of quick sort, but it not always works correctly. The main thing on interview of it do not tell

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, A13x, you wrote: RF>> There is an algorithm of quick sort, but it not always works correctly. A> the main thing on interview of it do not tell Yes a hogwash, the Chemist, I think, at once .

#### Re: What algorithms of sorting of an array of the big length advise?

Corrected now the code in algorithm of quick sort with a recursion - interposed checks on that i did not exceed last, and j did not exceed first (first and last - accordingly the beginning and the end of a processed interval, i increases from first, j decreases from last) - and all works normally! That on increase that on decrease.

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, Khimik, you wrote: K> At  sortings are compared the elements lying nearby, and there should be the Boolean variable, whether defining there were changes in the last iteration. In my algorithm of it is not present. And I like was mistaken a few - the second cycle should be launched from I to N, instead of from I+1 to N. Under the description - sorting by a choice.

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, Privalov, you wrote: P> I while met exactly one specific task: to sort surnames in alphabetic order in the Ukrainian language. Some letters of the Ukrainian language took wrong places in the table. And that, it was for a long time. For this purpose sorting is not necessary. The predicate is for this purpose necessary.... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, WolfHound, you wrote: WH> sorting For this purpose is not necessary. The predicate is for this purpose necessary. I in course

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, RussianFellow, you wrote: RF> Dear colleagues, what algorithms of sorting of an array of the big length (to 10000 elements) advise? There is an algorithm to which for one pass can sort swap-file bytes

#### Re: What algorithms of sorting of an array of the big length advise?

Hello, smeeld, you wrote: S> Hello, RussianFellow, you wrote: RF>> Dear colleagues, what algorithms of sorting of an array of the big length (to 10000 elements) advise? S> any which with support of multinuclear possibilities of the processor for 10K elements parallel sorting is not necessary: synchronization eats more than  advantages gives - there only it is necessary ~ 10K+13.28 iterations, i.e. approximately 20 clock periods on all sorting, and simply descent  from  - 2K clock periods. It is not necessary  manufactures...