Here's a start. Rename the module or cut & paste the proxy class block into one of your modules.
module Sort
class << self
def sort_faces_by_vertex()
@sel = Sketchup.active_model.selection.to_a
@sel.delete_if {|e| not e.is_a?(Sketchup;;Face) }
@sel.sort! {|a,b|
([a.vertices.min{|v1,v2| v1.position.x <=> v2.position.x }.position.x,
a.vertices.min{|v1,v2| v1.position.y <=> v2.position.y }.position.y] <=>
[b.vertices.min{|v1,v2| v1.position.x <=> v2.position.x }.position.x,
b.vertices.min{|v1,v2| v1.position.y <=> v2.position.y }.position.y] )
}
end
def assign_room_nums_to_faces()
sbv = sort_faces_by_vertex()
sbv.each_with_index {|face,i|
dict = face.attribute_dictionary('Properties',true)
dict['name']= "Room #{(i+1).to_s}"
}
end
end # proxy class
end # module Sort