Here's a considerably more readable version, though I haven't yet tried it out.
```coffee
# app/assets/javascripts/active_admin/components/has_many_sortable.js.coffee
reindexSort = ($context, inputName)->
  $sortInputs = $("input[name$='#{inputName}']", $context)
  $sortInputs.each (index)->
    $(@).val(index)

$('.has_many.sortable').each ->
  $hasMany  = $(@)
  inputName = $hasMany.attr('data-sortable-input')

  $("li[id$='#{inputName}']", $hasMany).hide()
  reindexSort($hasMany, inputName)

  $(@).sortable
    items: 'fieldset',
    update: (event, ui)->
      reindexSort($hasMany, inputName)
```