Those are all good cars. The Sonata is a size bigger than the Elantra and typically comes with more extras. Its gas mileage might be a little lower, but that probably won’t be a big deal unless you expect to have a super long commute in the future. I like that generation of Sonata quite a lot better than that Elantra, which is a cheaper feeling car. The Sonata is just bigger, quieter, and better looking. The back seat is considerably roomier than the other two. My mother has a Civic of that generation and it has been very good to her. I always enjoy riding in that car, though hers is a top-spec EX and you’re looking at a more basic DX. However, the basic car isn’t all that different. The DX won’t have a sunroof or the nicer upholstery, but it will drive just fine and be very well made.
If all else was equal (miles, condition) I’d probably take the Sonata first, Civic second, and Elantra last. But it really comes down to condition as any of these could be a perfectly maintained gem or an abused lump of coal. The Civic has almost always been a good, solid car. Hyundai made a lot of bad cars before getting it together, but that Sonata is a good car, and the Elantra a decent one. You need to line up a mechanic who can do a basic inspection of any car you’re interested in. Have him look at whichever heads up your mental list and pay deep attention to work he says needs to be done now or very soon. Get rough cost estimates from him for the work (make it clear you’re not seeking bids, just want numbers to compare cars.)