Duplicate duplicates the wrong rows in a sorted table

I believe this is another manifestation of the same underlying problem in this bug, but it’s a far more visible and frustrating occurrence.

Steps to reproduce:

1: Create a table with three rows, and put entries “A”, “Z”, and “M”, in that order, in one column:

image

2: Sort the table ascending on this column:


image

3: Select the first two rows:

image

  1. Right-click and hit “duplicate 2 rows”:

image

Expected Result

The selected rows are duplicated.

Actual Result

Two rows are duplicated, just not what you selected:

image

Analysis

Coda appears to treat “Duplicate N rows” as “Duplicate N rows starting at @TheFirstOne”. Since the sort is not applied at the dataset level, the rows to be duplicated are calculated on the unsorted data, which has Z immediately following A.