class Array def stable_sort n = 0 sort_by {|x| n+= 1; [x, n]} end end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Stable sort (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Сортир... in ruby sort array
» Stable Sort in ruby sort stable array
» Mergesort in ruby sort stable mergesort
» .inputrc (Mac OS X) / .bashr... in ruby sort processmanagement mod_security date zsh osx mac css paypal launchd compiler bashrc cache exception script htaccess line java vbscript lighttpdctrl linux cli filter package vim file makingmylifeeasier url browser perforce IMVU autoit basic mongrel_cluster geektool permissions session grayscale pmwiki altering facebook tree only sftp rar launchctl leopard SOAP4R adsl mtu root mechanize hidden tool groovy xpath sudo batch jdk variable options forums cupsd emerge war system serial inputrc rdbm upper afplay pipestatus rule accordion packagemaker newpldir corner realpath operator guid m4v subs2srt laptop report Sample Is move zendesk ie8 load ul relative pad seconds conver fifo xelatex otf Wrinkle DataSet Remoting css3 objective printerStatus realtime
» JQuery ToggleVal in ruby sort processmanagement mod_security date zsh css paypal launchd compiler cache exception script htaccess line java vbscript lighttpdctrl cli filter package vim file makingmylifeeasier url browser perforce IMVU autoit basic mongrel_cluster geektool permissions jquery session grayscale pmwiki altering facebook tree only sftp rar launchctl leopard SOAP4R adsl mtu root mechanize hidden tool groovy xpath sudo batch jdk variable options forums cupsd emerge war system serial rdbm upper afplay pipestatus rule accordion packagemaker newpldir corner realpath operator guid m4v subs2srt laptop report Sample Is move zendesk ie8 load ul relative pad seconds conver fifo xelatex otf Wrinkle DataSet Remoting css3 objective printerStatus realtime ToggleVal
» General get value from possi... in ruby sort processmanagement mod_security date zsh css paypal launchd compiler input cache exception script htaccess line java vbscript lighttpdctrl cli filter package value vim file makingmylifeeasier GET url browser perforce IMVU autoit basic mongrel_cluster geektool permissions session grayscale pmwiki altering facebook tree only sftp rar launchctl leopard SOAP4R adsl mtu root mechanize hidden tool sources groovy xpath sudo batch jdk General variable options forums cupsd emerge war system serial rdbm upper afplay pipestatus rule accordion packagemaker newpldir corner realpath operator guid m4v subs2srt laptop report Sample Is move zendesk ie8 load ul relative pad seconds conver fifo xelatex otf Wrinkle DataSet Remoting css3 objective printerStatus realtime possible
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails