Fixed sort algorithm in flattenArray for object values

Signed-off-by: Tom Wright <tom@inflatablecookie.com>