The curious case of Modern Document Sets
Table of Contents
All the way back in May of 2023, I shared a “hack” I’d found to enable Document Sets in SharePoint Online to have a modern experience when being created.
Taking the creation experience from the classic SharePoint form this

to this

Simply setting the value of NewFormClientSideComponentId on the Document Set content type to the null. this is a field used for SPFx custom forms, but when set to null. SharePoint somehow falls back to the modern form experience, which cannot be done out of the box.
See the script sample here for more details.
Skip to 2025
The year is now 2025, and I still can’t find any official documentation from Microsoft about this feature, nor have I seen any issues, two and a half years later, I, and dozens of others, continue to use this approach without any issues.
That was until Friday, October the 10th, when an email came in from Bastiaan Kortenbout, a fellow SharePoint enthusiast, asking if I too had observed issues with Modern Document Sets.
As it turns out Bastiaan, was using the method in a configuration/use case I’d never tested.
The sorting issue
Normally when I’m using Document Sets, they’re the “outer most layer” of my data, so nothing but Document Sets go in the root of a document library.
But, as it turns out, Bastiaan was using Document Sets mixed with folders, meaning that in the root of his document library, he had both Document Sets and regular folders, and even regular files.
Now nothing is wrong with this approach, but it highlighted an interesting issue with the sorting of Document Sets, as it turns out, normally document sets are sorted among files, and folders kept at the top of the view.
But with modern Document Sets, they now behave like folders. That is until you either capture a version, or copy/move them, which somehow makes them sort with files again.

This results in a confusing experience for end users, as the Modern Document Sets appear with the folders, while classic Document Sets appear with the files.
The fix
Bastiaan did some digging, and found that the issue was related to the hidden SortBehavior field, which appears to control the sorting of folders, and files, so he created a quick view including this field, validated this theory.
Add-PnPView -List "Document Library" -Title "TestView" -Fields "LinkFilename","SortBehavior"

Lo and behold, it all makes sense.
Document Sets created using the modern form have a SortBehavior value of 1, which is the same as folders, while classic Document Sets have a SortBehavior value of 0, which is the same as files.
Now making changes to this field directly is not supported, as it’s a hidden field, and changing it may have unintended consequences - but what Bastiaan found, is capturing a version, or copy/moving the Document Set, changed the SortBehavior field was reset to 0.
Which means that they’re now sorted with files again.
Bastiaan and I evaluated the situation, over mail, and Bastiaan came up with two options.
Option 1: Change the view settings (preferred)
Under the classic view settings, there’s an option to “Sort only by specified criteria (folder may not appear before items)” setting, while it may not be desirable in all cases, it’s probably the best solution in this scenario

This does however mean that folders will no longer appear at the top of the view, but mixed with items and Document Sets, so be sure to communicate this to your end users or just make sure you have a separate view for inside your Document Sets, which doesn’t have this flag set.
Option 2: Disable modern Document Sets
The other, and more nuclear option is to disable the modern Document Set experience the library, using this snippet
$docLib = Get-PnPList -Identity "Document Library"
$ct = Get-PnPContentType -List $docLib -Identity "Document Set"
$ct.NewFormUrl = "_layouts/15/NewDocSet.aspx"
$ct.Update($false)
Invoke-PnPQuery
And then update the SortBehavior field on the modern Document Sets to 0, so they’re sorted with files again, by capturing a version on all of the ones that are still set to SortBehavior set to 1 using this snippet.
# Get all Document Sets
$docsets = Get-PnPListItem -List $listName -PageSize 500 | Where-Object {
$_["HTML_x0020_File_x0020_Type"] -eq "Sharepoint.DocumentSet"
}
# Filter for those with SortBehavior = 1
$targets = $docsets | Where-Object {
$_["SortBehavior"] -and $_["SortBehavior"].LookupValue -eq "1"
}
Write-Host "Found $($targets.Count) Document Sets with SortBehavior = 1."
foreach ($ds in $targets) {
$name = $ds["FileLeafRef"]
$id = $ds["ID"]
try {
Write-Host "Processing Document Set: $name (ID: $id)"
# Get the list item again to ensure all properties are loaded
$listItem = Get-PnPListItem -List $listName -Id $id
# Capture a new version
$listItem.UpdateOverwriteVersion()
Invoke-PnPQuery
Start-Sleep -Seconds 2
# Recheck SortBehavior value
$updated = Get-PnPListItem -List $listName -Id $id
$newSort = $updated["SortBehavior"].LookupValue
Write-Host "Version captured. SortBehavior now: $newSort"
}
catch {
Write-Host "Failed for ${name}: $($_.Exception.Message)"
}
}
Now all modern Document Sets appear mixed in with classic Document Sets and files, just like one would expect, out of the box.
TL;DR
The Document Set modernisation hack from years ago still works, however, there’s a twist, modern Document Sets have a SortBehavior field set to 1, which sorts them with folders, at the top of views, while classic Document Sets have a SortBehavior field set to 0, which sorts them with files.
Even more curiously, once you capture a version, or copy/move a modern Document Set, the SortBehavior field is reset to 0, making them sort with files again - causing inconsistency in the user experience, as some Document Sets may appear with folders, while others appear with files.
This is all fixable either by changing the view settings to not prioritize folders at the top, or by disabling modern Document Sets, and capturing a version on all modern Document Sets to reset their SortBehavior field to 0.