<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>22313</bug_id>
          
          <creation_ts>2009-11-17 01:51:02 +0300</creation_ts>
          <short_desc>sort -R не перемешивает дублирующиеся строки</short_desc>
          <delta_ts>2009-11-17 14:12:31 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>coreutils</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Alexey Gladkov">legion</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>php-coder</cc>
    
    <cc>placeholder</cc>
    
    <cc>vt</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>103228</commentid>
    <comment_count>0</comment_count>
    <who name="Alexey Gladkov">legion</who>
    <bug_when>2009-11-17 01:51:02 +0300</bug_when>
    <thetext>Если в входном потоке есть повторяющиеся строки, то на выходе они всегда оказываются рядом:

$ export LANG=C
$ for i in `seq 1 1000`; do printf &apos;aaa\nbbb\naaa\nccc\nddd\naaa\neee\n&apos; |sort -R |uniq |wc -l; done |uniq
5

Опция --random-source эффекта не оказывает.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103229</commentid>
    <comment_count>1</comment_count>
    <who name="Slava Semushin">php-coder</who>
    <bug_when>2009-11-17 07:24:14 +0300</bug_when>
    <thetext>Это by design; опция -R не совсем сортирует в случайном порядке, она берёт случайную хэш функцию, применяет её к каждой строке и потом сортирует их по полученным хэшам, т.о. выглядит это очень похоже на случайное перемешивание, но это не совсем так.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103242</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Gladkov">legion</who>
    <bug_when>2009-11-17 13:26:25 +0300</bug_when>
    <thetext>Тогда в ман странице нужно написать правду. Так как лично я фразу &quot;sort by random hash of keys&quot; понял как &quot;сортировка по случайному хэшу от ключа&quot;. Из описания не понятно, применяется ли одинаковая процедура хэширования ко всем ключам или нет.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103243</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2009-11-17 14:04:38 +0300</bug_when>
    <thetext>sort(1) manpage выглядит лаконичной версией info sort, в котором написано:
&quot;Sort by hashing the input keys and then sorting the hash values. Choose the hash function at random, ensuring that it is free of collisions so that differing keys have differing hash values. This is like a random permutation of the inputs, except that keys with the same value sort together.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103245</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Gladkov">legion</who>
    <bug_when>2009-11-17 14:12:31 +0300</bug_when>
    <thetext>(В ответ на комментарий №3)
&gt; sort(1) manpage выглядит лаконичной версией info sort, в котором написано:
&gt; &quot;Sort by hashing the input keys and then sorting the hash values. Choose the
&gt; hash function at random, ensuring that it is free of collisions so that
&gt; differing keys have differing hash values. This is like a random permutation of
&gt; the inputs, except that keys with the same value sort together.&quot;

Тогда вопросов не имею. Сам виноват.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>