问题描述我有这样一个json数组a=[{"id":863,"hostname":"hdfs"},{"id":822,"hostname":"admin"},{"id":865,"hostname":"Spark-1"},{"id":1074,"hostname":"Spark-10"},{"id":867,"hostname":"Spark-2"},{"id":1014,"hostname":"Spark-11"}]通过sort按hostname字段排序a.sort(key=lambdax:x["hostname"])得到的是这样的结果Spark-10在Spark-2前面[{"id":822,"hostname":"admin"},{"id":863,"hostname":"hdfs"},{"id":865,"hostname":"Spark-1"},{"id":1074,"hostname":"Spark-10"},{"id":1014,"hostname":"Spark-11"},{"id":867,"hostname":"Spark-2"},]而我希望得到这样一个结果[{"id":822,"hostname":"admin"},{"id":863,"hostname":"hdfs"},{"id":865,"hostname":"Spark-1"},{"id":867,"hostname":"Spark-2"},{"id":1074,"hostname":"Spark-10"},{"id":1014,"hostname":"Spark-11"}]请问我改如何进行处理
料青山看我应如是
相关分类