[BangPypers] Sort names in a list by order of importance

S Pratap Singh kdarious at gmail.com
Tue Apr 24 08:36:41 CEST 2012

I need to sort list with names and without loosing the alphabet case (lower
or upper). In each list last name is important and should get priority in
sorting. If there are two or more name similar to the last name in the
list. Then the last name should be printed first before another similar

Also we need to sort the name based on the initials (sir name). If the name
does not have initial then the first name should be considered as initial.

There are no asterisks in the list

mylist = ["Alan","aLan","alAn","alaN","ALan","AlAn","AlaN","aLAn","aLaN",*"alAN"*]

I just highlighted the last name in the list as this is very important name
and it should be printed before any other similar name in the list.

Let me know if this makes sense to you.

On Tue, Apr 24, 2012 at 9:11 AM, Gora Mohanty <gora at mimirtech.com> wrote:

> On 24 April 2012 01:13, S Pratap Singh <kdarious at gmail.com> wrote:
> [...]
> > Above works fine but in the scenario mentioned below it fails :
> >
> >>>> mylist =
> ["Alan","aLan","alAn","alaN","ALan","AlAn","AlaN","aLAn","aLaN",*"alAN"*]
> This is a syntax error. What do you mean by the asterisks?
> [...]
> > The desired output should be like this :
> >
> > [ *"alAN"*, "aLaN", "aLAn", "AlaN", "AlAn", "ALan", "alaN", "alAn",
> > "aLan", "Alan" ]
> Could you define the desired sort order in words. This
> is not making sense to me.
> Regards,
> Gora
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers

Pratap Singh

More information about the BangPypers mailing list