[EP Perf] Fix sort (#18174)

### Description
Existing sort can't handle the index within test data folders/inputs
name string correctly, when index is larger than 10
Update the logic to sort based on index fetched by regex
This commit is contained in:
Yifan Li 2023-11-02 08:05:08 -07:00 committed by GitHub
parent dabd395fdf
commit f9d5705db4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,7 +89,13 @@ TRT_ENGINE_CACHE_DIR_NAME = "engine_cache"
def split_and_sort_output(string_list):
string_list = string_list.split("\n")
string_list.sort()
def custom_sort(item):
# Parse digits
numbers = re.findall(r"\d+", item)
return int(numbers[0]) if numbers else float("inf")
string_list.sort(key=custom_sort)
return string_list