Skip to content
Advertisement

sorting a list of females and males

I have an input:

JavaScript

and I must sort it in the way that first comes all f(females) ordered by alphabet then comes all m(males) ordered by alphabet. This is the desirable output:

JavaScript

.here is my code:

JavaScript

my code dose not sort f.(females) correctly and Sara comes first. Could anybody help me?

Advertisement

Answer

Try this, it should be fine

JavaScript

Output :

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement