把数组排成最小的数(important)

题目描述
输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。

# -*- coding:utf-8 -*-
class cmp(str):
    def __lt__(a,b):
        return a+b<b+a

class Solution:
    def PrintMinNumber(self, numbers):
        return ''.join(sorted(map(str,numbers),key=cmp))
原文地址:https://www.cnblogs.com/bernieloveslife/p/10427077.html