Preserve order of rows of Table after key_by()


Here you can see that the order is changed after I am setting the keys with key_by(). Unfortunately the order of the first table is for me really important. Is there a way to preserve it?


key_by as currently implemented sorts by the key. If you want to preserve the order, you could either not key it, key by something that preserves the order, or resort it back at the end before exporting.

What is the reason you need to key?

I solve it by using add_index and order_by(ht.idx)

The user is giving as an input an object of variants which has an order, the output is just an array for example with the GT values