diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index f95f5a29de908a48170e7cd9e119c90408c3403d..13696eabf1bec4a76d00af7b8ddc04ba86eb917a 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -906,7 +906,7 @@ static int l_get_modnames(lua_State *L)
 	{
 		bool added = false;
 		for(std::list<std::string>::iterator x = mods_sorted.begin();
-		    x != mods_unsorted.end(); ++x)
+		    x != mods_sorted.end(); ++x)
 		{
 			// I doubt anybody using Minetest will be using
 			// anything not ASCII based :)