Edit Script error

Hello, I can not find out what I doing wrong. I received error:
Multiple markers at this line

  • Cannot read property “fields” from undefined
  • Record index ‘33’ is out of range

I try make a sort on the detail table - I need sort by the ‘Total’ column:

var items=;
results.each(function(index) {
field = record.tables[“detail”][index].fields[‘Total’];
items.push(field);
});

items.sort();
results.each(function(index) {
this.html(items[index]);
});

Thank You

This is a duplicate question that was addressed in this other topic.