input: from typing import List
  
  def gini(x: List[float]) -> float:
      """Calculate 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
      """
      # Sort the list to make sure the values are ordered for the Gini calculation
      x_sorted = sorted(x)
      
      # Calculate the cumulative sum of the sorted values
      n = len(x_sorted)
      cum_x = [x_sorted[i] * (n - i) for i in range(n)]
      cum_sum_x = sum(cum_x)
      
      # Calculate the Gini Coefficient
      if n == 0:
          return 0
      return (2 * cum_sum_x / (n * sum(x_sorted))) - (n + 1) / n
  
output:     # Sort the list to make sure the values are ordered for the Gini calculation
      x_sorted = sorted(x)
      
      # Calculate the cumulative sum of the sorted values
      n = len(x_sorted)
      cum_x = [x_sorted[i] * (n - i) for i in range(n)]
      cum_sum_x = sum(cum_x)
      
      # Calculate the Gini Coefficient
      if n == 0:
          return 0
      return (2 * cum_sum_x / (n * sum(x_sorted))) - (n + 1) / n