Plist Item Numbering Seems to be Arbitrary?

Hello all, I’m trying to do something that will read plist items in order and utilize them, but when I loop through them and get their values, they seem to be mismatched. Here is the plist:

<?xml version="1.0" encoding="UTF-8"?> Test1 Test1 Test2 Test2 Test3 Test3 Test4 Test4 Test5 Test5

And here is the code I’m using to loop through the items:


tell application "System Events"
	tell property list file thePath
		repeat with i from 1 to (count property list items)
			log "i: " & i & ", value: " & value of property list item i & ""
		end repeat
	end tell
end tell

And this is what it returns:


tell application "System Events"
	count every property list item of property list file "~/Desktop/ATIS_Data.plist"
		--> 5
	get value of property list item 1 of property list file "~/Desktop/ATIS_Data.plist"
		--> "Test1"
	(*i: 1, value: Test1*)
	get value of property list item 2 of property list file "~/Desktop/ATIS_Data.plist"
		--> "Test3"
	(*i: 2, value: Test3*)
	get value of property list item 3 of property list file "~/Desktop/ATIS_Data.plist"
		--> "Test5"
	(*i: 3, value: Test5*)
	get value of property list item 4 of property list file "~/Desktop/ATIS_Data.plist"
		--> "Test2"
	(*i: 4, value: Test2*)
	get value of property list item 5 of property list file "~/Desktop/ATIS_Data.plist"
		--> "Test4"
	(*i: 5, value: Test4*)
end tell

It seems to be going through the odd numbered items and then the even numbered items, so I guess my questions are: why? and: how do I make it go through sequentially, if possible?

A plist file is a key-value pairing represented internally by NSDictionary, and NSDictionary objects are unordered collections. I think the reason for that is speed: keys are represented by hashes which can be accessed more quickly, but the hash ordering is unrelated to any natural ordering of the keys themselves. If you have a key that holds an array as a value, the ordering of the array elements will be fixed, but you can’t rely on the order in which the keys are processed.

Ah I see, thank you so much for your help!