title: Python Program to Implement Bucket Sort: Is there a better way to create a bucket?
body: <p>I have initialized the bucket with np.empty and after with np.nan. Is it the better way? I did not know how to create a truly empty array!  I need an EMPTY array with 10 rows and len(array) columns</p>
  
  <p>The code below is the first part of the algorithm. The code is working!</p>
  
  <p>Another question: I used "for" to iterate through the bucket, which is a numpy array.Is it correct? </p>
  
  <pre><code>import numpy as np
  
  class BucketSort():
      def __init__(self,array):
          self.array = array
      def distribution_pass(self):
          bucket = np.empty((10,len(self.array)),dtype=int)
          bucket[:] = np.nan
          #rows =[]
         # cols = []
          for num in array:
              for j in range(bucket.shape[1]):
                  bucket[num % 10, j] = num
                  #rows.append(num%10)
                  #cols.append(j)
                  break
                  print()
  
          return bucket
      def gathering_pass(self):
          array = []
          self.bucket = BucketSort.distribution_pass(self)
          for i in range(self.bucket.shape[0]):
              for j in range(self.bucket.shape[1]):
                if not np.isnan(self.bucket[i,j]):
                    #print(self.bucket[i,j])
                    array.append(self.bucket[i, j])
  
          return array
  
  
  def main(array):
      bucket = BucketSort(array)
      BucketSort.distribution_pass(bucket)
      array = BucketSort.gathering_pass(bucket)
      return array
  
  
  array = [97,3,100]
  print(main(array))
  #bucket = BucketSort(array)
  #print(bucket.distribution_pass())
  #print(bucket.gathering_pass())
  </code></pre>
  
  <p>Input: <code>[97,3,100]</code></p>
  
  <p>Output: <code>[100,3,97]</code></p>