Computing the inertial axes is a 3D eigenvalue problem, with the principal axis corresponding to the smallest eigenvalue, i.e. the axis with least inertia wrt. rotation around the axis.
The secondary and tertiary axes are orthogonal to the primary axis, with successively larger inertia (eigenvalues), as more mass is rotated.
One thing to note is that the direction of the principal axis is arbitrary, in terms of the sign of the vector components. For example, the principal inertial axis of a helix could point in either direction.