diff --git a/Source/Core/Common/FatFsUtil.cpp b/Source/Core/Common/FatFsUtil.cpp index 3ad4fd9fb3..1423bd4815 100644 --- a/Source/Core/Common/FatFsUtil.cpp +++ b/Source/Core/Common/FatFsUtil.cpp @@ -485,10 +485,7 @@ static bool Pack(const std::function& cancelled, const File::FSTEntry& e static void SortFST(File::FSTEntry* root) { - std::sort(root->children.begin(), root->children.end(), - [](const File::FSTEntry& lhs, const File::FSTEntry& rhs) { - return lhs.virtualName < rhs.virtualName; - }); + std::ranges::sort(root->children, {}, &File::FSTEntry::virtualName); for (auto& child : root->children) SortFST(&child); } diff --git a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp index 468b68bebf..96ce91b275 100644 --- a/Source/Core/Core/IOS/FS/HostBackend/FS.cpp +++ b/Source/Core/Core/IOS/FS/HostBackend/FS.cpp @@ -686,17 +686,17 @@ Result> HostFileSystem::ReadDirectory(Uid uid, Gid gid, // Now sort in reverse order because Nintendo traverses a linked list // in which new elements are inserted at the front. - std::sort(host_entry.children.begin(), host_entry.children.end(), - [&get_key](const File::FSTEntry& one, const File::FSTEntry& two) { - const int key1 = get_key(one.virtualName); - const int key2 = get_key(two.virtualName); - if (key1 != key2) - return key1 > key2; + std::ranges::sort(host_entry.children, + [&get_key](const File::FSTEntry& one, const File::FSTEntry& two) { + const int key1 = get_key(one.virtualName); + const int key2 = get_key(two.virtualName); + if (key1 != key2) + return key1 > key2; - // For files that are not in the FST, sort lexicographically to ensure that - // results are consistent no matter what the underlying filesystem is. - return one.virtualName > two.virtualName; - }); + // For files that are not in the FST, sort lexicographically to ensure that + // results are consistent no matter what the underlying filesystem is. + return one.virtualName > two.virtualName; + }); std::vector output; for (const File::FSTEntry& child : host_entry.children) diff --git a/Source/Core/Core/PowerPC/PPCTables.cpp b/Source/Core/Core/PowerPC/PPCTables.cpp index 24d9040c6e..3e8bfe27cf 100644 --- a/Source/Core/Core/PowerPC/PPCTables.cpp +++ b/Source/Core/Core/PowerPC/PPCTables.cpp @@ -16,6 +16,7 @@ #include "Common/FileUtil.h" #include "Common/IOFile.h" #include "Common/Logging/Log.h" +#include "Common/Projection.h" #include "Common/StringUtil.h" #include "Core/PowerPC/PowerPC.h" @@ -694,8 +695,7 @@ void PrintInstructionRunCounts() const GekkoOPInfo& info = s_tables.all_instructions[i]; temp[i] = std::make_pair(info.opname, info.stats->run_count); } - std::sort(temp.begin(), temp.end(), - [](const OpInfo& a, const OpInfo& b) { return a.second > b.second; }); + std::ranges::sort(temp, std::ranges::greater{}, Common::Projection::Second{}); for (auto& inst : temp) { diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index 5d080afe1d..442c8ae851 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -1192,15 +1192,13 @@ void DirectoryBlobPartition::WriteDirectory(std::vector* fst_data, std::vector& sorted_entries = *parent_entries; // Sort for determinism - std::sort(sorted_entries.begin(), sorted_entries.end(), - [](const FSTBuilderNode& one, const FSTBuilderNode& two) { - std::string one_upper = one.m_filename; - std::string two_upper = two.m_filename; - Common::ToUpper(&one_upper); - Common::ToUpper(&two_upper); - return one_upper == two_upper ? one.m_filename < two.m_filename : - one_upper < two_upper; - }); + std::ranges::sort(sorted_entries, [](const FSTBuilderNode& one, const FSTBuilderNode& two) { + std::string one_upper = one.m_filename; + std::string two_upper = two.m_filename; + Common::ToUpper(&one_upper); + Common::ToUpper(&two_upper); + return one_upper == two_upper ? one.m_filename < two.m_filename : one_upper < two_upper; + }); for (FSTBuilderNode& entry : sorted_entries) { diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp index 18ef37102e..dc67760ce2 100644 --- a/Source/Core/DiscIO/VolumeVerifier.cpp +++ b/Source/Core/DiscIO/VolumeVerifier.cpp @@ -1053,8 +1053,7 @@ void VolumeVerifier::SetUpHashing() m_scrubber.SetupScrub(m_volume); } - std::sort(m_groups.begin(), m_groups.end(), - [](const GroupToVerify& a, const GroupToVerify& b) { return a.offset < b.offset; }); + std::ranges::sort(m_groups, {}, &GroupToVerify::offset); if (m_hashes_to_calculate.crc32) m_crc32_context = Common::StartCRC32(); diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index c59802c947..3f91a606aa 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -941,8 +941,7 @@ ConversionResultCode WIARVZFileReader::SetUpDataEntriesForWriting( if (volume && volume->HasWiiHashes() && volume->HasWiiEncryption()) partitions = volume->GetPartitions(); - std::sort(partitions.begin(), partitions.end(), - [](const Partition& a, const Partition& b) { return a.offset < b.offset; }); + std::ranges::sort(partitions, {}, &Partition::offset); *total_groups = 0; diff --git a/Source/Core/UICommon/ResourcePack/Manager.cpp b/Source/Core/UICommon/ResourcePack/Manager.cpp index eda0e9c93b..b1fd555c85 100644 --- a/Source/Core/UICommon/ResourcePack/Manager.cpp +++ b/Source/Core/UICommon/ResourcePack/Manager.cpp @@ -53,9 +53,7 @@ bool Init() pack_list_order.emplace_back(OrderHelper{i, std::move(manifest_id)}); } - std::sort( - pack_list_order.begin(), pack_list_order.end(), - [](const OrderHelper& a, const OrderHelper& b) { return a.manifest_id < b.manifest_id; }); + std::ranges::sort(pack_list_order, {}, &OrderHelper::manifest_id); bool error = false; for (size_t i = 0; i < pack_list_order.size(); ++i) diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp index 0001a9081d..b52df66e31 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp @@ -165,10 +165,8 @@ std::vector GlobalConflicts(std::string_view source) // Sort the conflicts from largest to smallest string // this way we can ensure smaller strings that are a substring // of the larger string are able to be replaced appropriately - std::sort(global_result.begin(), global_result.end(), - [](const std::string& first, const std::string& second) { - return first.size() > second.size(); - }); + std::ranges::sort(global_result, std::ranges::greater{}, + [](const std::string& s) { return s.size(); }); return global_result; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 61882476d7..70a753931a 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -2026,8 +2026,7 @@ void TextureCacheBase::StitchXFBCopy(RcTcacheEntry& stitched_entry) if (candidates.empty()) return; - std::sort(candidates.begin(), candidates.end(), - [](const TCacheEntry* a, const TCacheEntry* b) { return a->id < b->id; }); + std::ranges::sort(candidates, {}, &TCacheEntry::id); // We only upscale when necessary to preserve resolution. i.e. when there are upscaled partial // copies to be stitched together.