Make text list from group names

How can I get a text list of all Group names at the root level. Purpose is to use the list as keywords to search imported files.

This might be one approach:

tell application id "DNtp"
	set {dlm, my text item delimiters} to {my text item delimiters, linefeed}
	set strNames to (name of children of root of front database where type = group) as text
	set my text item delimiters to dlm
	set strNames to do shell script "echo " & quoted form of strNames & " | sort"
end tell

Thanks that works