All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
Soorah Luqmaan [Quran 31] was revealed before Soorah Al-Kahf [Quran 18], as was stated by Al-Khaazin in his Tafseer (interpretation of the Quran) entitled Lubaab Al-Quran when he listed the order of the revelation of the Chapters that were revealed in Makkah.
Allaah knows best.