Improve import order script in api (1-3-stable)

Similar to #3788 but for 1-3-stable