<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Moose56's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 08 Aug 2008 19:20:49 GMT</pubDate>
    <description>DZone Snippets: Moose56's Code Snippets</description>
    <item>
      <title>Bubble Sort in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5452</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def bubble_sort(list)&lt;br /&gt;  return list if list.size &lt;= 1 # already sorted&lt;br /&gt;&lt;br /&gt;  loop do&lt;br /&gt;    swapped = false&lt;br /&gt;    0.upto(list.size-2) do |i|&lt;br /&gt;      if list[i] &gt; list[i+1]&lt;br /&gt;        list[i], list[i+1] = list[i+1], list[i] # swap values&lt;br /&gt;        swapped = true&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;    break unless swapped&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  list&lt;br /&gt;end&lt;/code&gt;</description>
      <pubDate>Fri, 02 May 2008 15:30:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5452</guid>
      <author>moose56 (David Madden)</author>
    </item>
    <item>
      <title>Selection Sort in Ruby</title>
      <link>http://snippets.dzone.com/posts/show/5451</link>
      <description>Simple implimentation of a selection sort in ruby&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def selection_sort(list)&lt;br /&gt;  return list if list.size &lt;= 1 # already sorted&lt;br /&gt;&lt;br /&gt;  0.upto(list.length-2) do |i|&lt;br /&gt;    min = i # smallest value&lt;br /&gt;    (i+1).upto(list.length-1) { |j| min = j if list[j] &lt; list[min] } # find new smallest&lt;br /&gt;    list[i], list[min] = list[min], list[i] if i != min #swap values&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  list&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 02 May 2008 14:38:19 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5451</guid>
      <author>moose56 (David Madden)</author>
    </item>
  </channel>
</rss>
