Detach By Element Then Groups Everything By Face Count

I would need a script that would detach meshes by Elements and group them by the face count of a desired amount. For example 1 - 1000 then 1001-5000 (and so on easy enough to add more things to get them organized) tris/polygons get grouped together and named the highest amount of it. Would need to group a stage for rendering ShadowMaps and Light Maps to make it all organized and speed up the process if thats possible.