Getting an object lined up with the x, y, or z axis again
Close the shape with ngon:


Add Empty to the scene, enable snapping, set to face, enable align orientation and snap the empty to the ngon:


Parent the mesh to the empty: Select mesh, select empty, Ctrl+P
Reset the rotation of empty with Alt+R
Clear parent (Alt+P) and Keep the transform. Now your mesh is aligned with world coords.
Delete Empty, delete ngon, rotate mesh to the axis you want.