Here's an example that shows you what normal is parallel or perpendicular.
(I'm not sorting the list, cause you say sorting, but then only care for parallel/ perp. ?)
- check the object type and if has faces
- list normals, including obj world rotation + scale
- compare with vector.dot so that 1/-1 are parallel, 0 is perpendicular
Note the > < 0.0001 comparison rather than == cause of the float precision issues.
from mathutils import Vector
orientZ = 
if Object is not None and getattr(Object, 'type', '') == 'MESH':
worldZ = Vector([0, 0, 1])
mat = Object.matrix_world
loc = mat.to_translation()
normals = [(mat * p.normal - loc).normalized() for p in Object.data.polygons]
# if dot is 0, is perpendicular, 1/-1 are up, down
for n in normals:
dotN = n.dot(worldZ)
if abs(dotN) > 0.9999: orientZ.append(1)
elif abs(dotN) < 0.0001: orientZ.append(0)
and gives a list of 1, 0, -1 for Z, perp, others
Another example is this
How can I compare normals in AN with python, doing the same, by distance compare to world XYZ axes.