If you want a solution in the Data Mapper,

Add an Action step with the below script which simply creates a multi-dimensional array of unique items sorted by id.

```
var sortedBooksList=[];
var bookCount = record.tables.books.length;
var bookFieldsCount = record.tables.books[0].fields.length;
var bookIndex;
var uniqueBooksList;
//SORT BOOKS
for(let i=0; i<bookCount; i++){
let bookFields = [];
for(let j=0; j<bookFieldsCount; j++){
if(record.tables.books[i].fields[j] == record.tables.books[i].fields['id']){
bookIndex = j;
}
bookFields.push(record.tables.books[i].fields[j]);
}
sortedBooksList.push(bookFields);
bookFields =[];
}
sortedBooksList.sort(function(a,b){
if(a[bookIndex].toLowerCase() < b[bookIndex].toLowerCase()) return -1;
if(a[bookIndex].toLowerCase() > b[bookIndex].toLowerCase()) return 1;
return 0;
});
// RETURN UNIQUE BOOKS
uniqueBooksList = groupUnique(sortedBooksList);
function groupUnique(arr) {
let uniques = [];
let booksFound = {};
for(let x = 0, l = arr.length; x < l; x++) {
let arrStr = JSON.stringify(arr[x]);
if(booksFound[arrStr]) { continue; }
uniques.push(arr[x]);
booksFound[arrStr] = true;
}
return uniques;
}
```

Once you have the array, it is just a matter of using the guide here to generate a detail table of sorted unique items with a Repeat Step

https://learn.objectiflune.com/howto/create-detail-table-linear-data-structure/

I have attached the new data mapping config file here.