input: Write a function to calculate the Gini coefficient of a given dataset.
  assert gini([2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,21])==0.605
output: def gini(data):
      n = len(data)
      if n == 0:
          return 0
      data.sort()
      total_sum = sum(data)
      gini_sum = 0
      for i, value in enumerate(data):
          gini_sum += (2 * (i + 1) - n - 1) * value
      return gini_sum / (n * total_sum)