The atomicity in the bash version can be "simply" achieved by copying the file to a temporary, modyfing it, then using `sync; mv; sync`, right?
And since you're copying, you could maybe ensure sorting, but I don't think doing that with "bash" (plus off the shelf utils) makes a lot of sense.
That's what DJBs CDB (cdbget, cdbmake, etc) is for: https://cr.yp.to/cdb.html