input: 
  from typing import List
  
  def gini(x: List[float]) -> float:
      """Calculate the Gini coefficient of a given dataset.
      
      >>> gini([2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21])
      0.605
      """
      import numpy as np
      
      # Convert list to numpy array for easier manipulation
      x = np.array(x)
      
      # Sort the array in ascending order
      x.sort()
      
      # Calculate the number of elements
      n = len(x)
      
      # Calculate the cumulative sums
      cum_x = x.cumsum()
      
      # Calculate the Gini coefficient
      gini_coef = (n + 1 - 2 * np.sum(cum_x) / cum_x[-1]) / n
      
      return gini_coef
  
output:     import numpy as np
      
      # Convert list to numpy array for easier manipulation
      x = np.array(x)
      
      # Sort the array in ascending order
      x.sort()
      
      # Calculate the number of elements
      n = len(x)
      
      # Calculate the cumulative sums
      cum_x = x.cumsum()
      
      # Calculate the Gini coefficient
      gini_coef = (n + 1 - 2 * np.sum(cum_x) / cum_x[-1]) / n
      
      return gini_coef