title: Program cannot Sort
body: <p>new to python , trying to learn oops ,
  in below code my objective is to sort employee list based on rating but stuck at object not iteratable.</p>
  <pre><code>class Employee:
      def getfn(self):
          self.empid=(input(&quot; enter emp id:&quot;))
          self.name=input(&quot;enter name:&quot;)
          self.gender=input(&quot;enter emp gender: &quot;)
          self.salary=input(&quot; enter emp salary:&quot;)
          self.rating=int(input(&quot;enter rating:&quot;))
  
  empz=[]
  class menu:
      n=0
      def entry(self):
          n=int(input(&quot; enter no of employees:&quot;))
          i=0
          while i&lt;n:
              temp_emp=Employee()
              temp_emp.getfn()
              empz.append(temp_emp)
              i+=1
      def print_rec(self):
           #
           print(&quot;-id--name--gender--salary--rating--&quot;)
           for i in empz:
               print(i.empid,i.name,i.gender,i.salary,i.rating)
           #print(sorted(empz,key=lambda x:x[4]))
  
  def sort_rating(empz):
      return empz.rating
  
  sorted_emp=sorted(empz, key= sort_rating)
  print(empz)
  </code></pre>