title: Bucket sort in C# - how to?
body: <pre><code>static void Main(string[] args)
  {
      double[] array = { 0.37, 0.25, 0.86, 0.23, 0.09, 0.21, 0.17, 0.71 };
      double[] sortedArray =BucketSort(array);
  
      // PrintResult(sortedArray);
  }
  
  public double[] BucketSort(double[] array)
  {
      List&lt;List&lt;double&gt;&gt; buckets = new List&lt;List&lt;double&gt;&gt;();
      InitializeBuckets(buckets);
  
      Scatter(array, buckets);
  
      int i = 0;
      foreach (List&lt;double&gt; bucket in buckets)
      {
          double[] arr = bucket.ToArray();
          InsertionSort(arr);
  
          foreach (double d in arr)
          {
              array[i++] = d;
          }
      }
  
      return array;
  }
  
  private void Scatter(double[] array, List&lt;List&lt;double&gt;&gt; buckets)
  {
      foreach (double value in array)
      {
          int bucketNumber = GetBucketNumber(value);
          buckets[bucketNumber].Add(value);
      }
  }
  
  private void InsertionSort(double[] array)
  {
      int j;
      double temp;
  
      for (int i = 1; i &lt; array.Length; i++)
      {
          j = i;
          while (j &gt; 0 &amp;&amp; array[j] &lt; array[j - 1])
          {
              temp = array[j];
              array[j] = array[j - 1];
              array[j - 1] = temp;
              j--;
          }
      }
  }
  
  private int GetBucketNumber(double value)
  {
      double val = value * 10;
      int bucketNumber = (int)Math.Floor(val);
      return bucketNumber;
  }
  
  private static void InitializeBuckets(List&lt;List&lt;double&gt;&gt; buckets)
  {
      for (int i = 0; i &lt; 10; i++)
      {
          List&lt;double&gt; a  = new List&lt;double&gt;();
          buckets.Add(a);
      }
  }
  </code></pre>
  
  <p>I get an error </p>
  
  <blockquote>
    <p>An Object reference is required for the non static field, method or property</p>
  </blockquote>
  
  <p>Can anyone solve this problem and explain it?</p>