I’d rather hang them on shore in Somalia. No trial, just take them in and hang them at the docks. A little of that and there’d be a marked decrease in piracy.
In the olden days, pirates were staked out in the sea at low tide and left to wait for high tide. That IS cruel (and these days, more than unusual). Just a simple hanging will suffice.