我想这个名单出来通过结束的每个元素分类编号: 人= [“james5”,“bill6”,“phil4”]排序列表出由一个特定的字符
换句话说,我想要的结果是: people = [“phil4”,“james5”,“bill6”]
Thanks!
我想这个名单出来通过结束的每个元素分类编号: 人= [“james5”,“bill6”,“phil4”]排序列表出由一个特定的字符
换句话说,我想要的结果是: people = [“phil4”,“james5”,“bill6”]
Thanks!
逆向每个项目阵列中的,排序,并再次反向排序后的数组
的各个项目的比较条件可以是如下,如果在完成C.逻辑是比较仅最后一个字符
char *str = people[i];
char *str1 = people[i+1];
if(str[strlen(str)-1] > str1[strlen(str1)-1])
{
//do the swap
}
与Python:
>>> people = ["james5", "bill6", "phil4"]
>>> def swap(l):
... return sorted([i[::-1] for i in l])
>>> people = [i[::-1] for i in swap(people)]
>>> print people
['phil4', 'james5', 'bill6']
这是什么语言?你有什么尝试? – TerryA 2013-03-17 09:43:25
语言是什么? – 2013-03-17 09:43:28