safeguard against null/undefined values when doing environment sort