This is not a total surprise.
The formal name for North Dakota Democrats is:
North Dakota Democratic-NPL Party
NPL is short for Non Partisan League. NPL was a prairie populist group that completely infiltrated the North Dakota Republican Party back in the 1910’s thru 1930’s. They advocated state control of grain milling, banks, etc.
Though North Dakota is a strong Republican state, there is still a strong undercurrent of prairie populism that exists. I’m not surprised that sanders did well there.
I was born there and have many farmer relatives there.
Though the state is generally quite conservative the farmers always elected democrat Senators because they promised more subsidies and other free stuff.