How to move elements based on condition?

Hello,

I’d like to create a table, where the user can add rows via a dedicated button.
He can also remove any row, which should result in the bottom rows moving up.

What’s the easiest way to control the location of elements (aka rows) based on a condition (aka user removes a row)?

Thanks