def ordinal(value):
 try:
  value = int(value)
 except (TypeError, ValueError):
  return value
 t = ('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th')
 if ((value % 100) in (11, 12, 13)):
  return (u'%d%s' % (value, t[0]))
 return (u'%d%s' % (value, t[(value % 10)]))

def ordinal ( value ) : try : value = int ( value ) except ( TypeError , ValueError ) : return value t = ( 'th' , 'st' , 'nd' , 'rd' , 'th' , 'th' , 'th' , 'th' , 'th' , 'th' ) if ( ( value % 100 ) in ( 11 , 12 , 13 ) ) : return ( u'%d%s' % ( value , t [ 0 ] ) ) return ( u'%d%s' % ( value , t [ ( value % 10 ) ] ) )
converts an integer to its ordinal as a string .