测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 688 字符 |
模型生成的代码 (688 字符)
def min_k(tuples_list, k):
"""
Return the minimum k records from the tuple list based on the second element of each tuple.
Parameters:
tuples_list (list of tuples): The input list of tuples, each tuple containing at least two elements.
k (int): The number of minimum records to return.
Returns:
list of tuples: A list containing the k tuples with the smallest second element, sorted ascending.
"""
# Sort by the second element using a stable sort to preserve original order for ties
sorted_list = sorted(tuples_list, key=lambda x: x[1])
# Return at most k elements (if k > len, return the whole sorted list)
return sorted_list[:k]
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试