以下是Python示例代码实现:
def sort_most_repeated_num_first(arr):
count = {}
for num in arr:
if num in count:
count[num] += 1
else:
count[num] = 1
sorted_count = sorted(count.items(), key=lambda x: x[1], reverse=True)
res = []
for num, freq in sorted_count:
for _ in range(freq):
res.append(num)
return res
使用示例:
arr = [1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 6, 6, 4, 4, 4]
print(sort_most_repeated_num_first(arr)) # [7, 4, 6, 1, 2, 3, 5]