I'm writing an installer script on Ubuntu for an application which needs multiple parts such as
- install a specific g++ version, put a script in profile.d, reboot
- install drivers for some hardware, remove old script, put new script in profile.d, reboot
- set environment variables, remove script from profile.d, add new script, compile source code (c++),
- set environment variables script int profile.d
At each part of the installation, I'm copying a script to the /etc/profile.d directory to be run at login from ssh. But I don't know if the script runs after all other scripts in same directory (for example, drivers may have put their own scripts in there which my script may need  to work).
How can I make sure my script in profile.d runs as a last step? Is it something about file name or creation date or something else?

/etc/profile. The scripts are sourced in this loopfor i in /etc/profile.d/*.sh; do(on Ubuntu 16.04).