at-import / Sassy-Maps

Map helper functions for Sass 3.3 and up
MIT License
66 stars 22 forks source link

Map Sort #1

Closed Snugug closed 9 years ago

Snugug commented 10 years ago

@HugoGiraudel Carry over from SassyLists #5

KittyGiraudel commented 10 years ago

So I've been thinking last night and I'm not sure there is a far more elegant way to do this that I haven't tried before. No matter the solution, you'll need a shared structure to order values from a list first. From there, you'll be able to sort either keys, or values, whatever.

So in the end, I'm not sure there is need to start again from scratch because as far as I can see (let's hope I'm wrong), there is no magic way to do so. Maybe you could refactorize the sort function to suit your coding standards (and let's hope you find some ways to make it simpler) but I don't think we can find a crazy way to sort maps without breaking those into lists first.

The big difference here is you'll be able to mark the sort function as a partial, not meant to be used on its own since it's clearly a helper for both map-sort-keys and map-sort-values.

What do you think?

Snugug commented 9 years ago

I think I'm going to close this as the point of maps (like objects in JS) is to get things by keys, not to rely on the key's order. If you'd like to issue a PR, I'm OK with it, as long as it covers all of the different data types that may be used for Sass map keys.

KittyGiraudel commented 9 years ago

Seconded. There is no point in sorting a map.