Ruby API split edge issue

fortunately, I solved it. I just leave the code here, in case someone needs it.

def sort_index(arg, arr)
  indices = 0
  arr.each do |ar|
    if arg < ar
      indices -= 1
    else
      indices += 1
    end
  end
  return indices
end

def sort_sequence(arr)
  indices = Hash.new
  arr.each do |arg|
    indices[sort_index(arg, arr)] = arg
  end
  _index = Array.new
  indices.sort.each do |ar|
    _index << ar[1]
  end
  return _index
end

def advanced_split(ed, p3ds)
  it = sort_sequence(p3ds).reverse
  it.each do |p3d|
    ed.split(p3d)
  end
end