Comments (22)
See also #29
from isotope.
Just spitballin' here...
Picking up on @joshhepworth idea in #29. I'm thinking that this could be achieved by adding a new option, multiSort
. It would accept an array. Each item in the array would be an object. Each item would have a sortBy
property, and an optional sortAscending
property. So it would look something like:
// sorts category, then price low-to-high, then most recent date
$('#container').isotope({
multiSort: [
{ sortBy: 'category' },
{ sortBy: 'price' },
{ sortBy: 'date', sortAscending: false }
]
});
This way, we can preserve backwards compatibility, and rely sortBy
and sortAscending
properties like before.
Right now, _sort()
is already hooked up to fallback to 'original-order'
if the first comparison matches. So you can already see how one might add a loop in there that uses the next object if the previous comparison matches.
I think this is totally do-able. I might take a swing at it in the next couple weeks.
from isotope.
+1 for some multiSort. I've got some users that are absolute junkies when it comes to sorting and filtering. May have a go at it this weekend myself.
from isotope.
+1 also
from isotope.
+1
from isotope.
+1
from isotope.
+1
from isotope.
I would rather see this implemented in a way that allowed more complete flexibility. The traditional solution to custom sorting would allow passing in a function that defined the sort:
$('#container').isotope({
sortBy: function($a,$b){
return $a.data('val') > $b.data('val');
}
});
The obvious consequence is the loss of the ability to index on item insertion since this would occur at sort-time, but unless there are HUNDREDS of elements in your grid this shouldn't be an issue.
This solution would allow any arbitrary sort to take place. It would also be a great model for complex filters.
from isotope.
@JoelSutherland That is a terrific solution. Easily for me to implement, and, like you said, provides for lots of flexibility.
Marking this for v1.6
from isotope.
Wow! That's awesome!
Not to get greedy...but would this be possible for filtering too?
$('#container').isotope({
filter: function($el){
return $el.data('val') > 5;
});
This would have the same benefit there and also potentially make the plugin easier to understand as a whole as both common methods would be similar.
from isotope.
check this for complex filtering
from isotope.
I know this is closed, but I don't see this on the documentation anywhere, and the referenced issue has been closed as well. Has this been implemented? If so, which version?
from isotope.
@ultimatedelman This issue is very much still open. No, this has not been implemented. Sorry, I'm not planning on resolving this in the near future. However, you are free to re-tool Isotope as you see fit to get it done.
from isotope.
@desandro would you be ok if i enabled the user to pass a comma-delimited string to indicate sort order? i know you're not down with "magic" args, but this is still a string, and if no commas are included, the original functionality would still work.
from isotope.
Ok, I rewrote the sorting algorithm a bit to incorporate a comma-delimited string and do a multi-sort based on that. This is just a proof of concept and hasn't really been tested with any of the other functionality isotope offers. I haven't really optimized it either, so I can't vouch for how efficient it is (maybe you can clean it up?) but I have done some of the heavy lifting for you. I'll clean this up a bit on my own and submit a pull request in a bit.
Hope this helps!
from isotope.
@ultimatedelman @desandro I am still getting a feel for isotope and infinity.js, but it (superficially) looks like there is some overlap with how @airbnb tracks element properties on continuous scroll views, using sorted arrays? They also mention that they are playing around with (balanced) binary trees: I believe those perform better in the worst cases than hash tables -- O(log(n)) vs. O(n).
from isotope.
thank you @ultimatedelman!
from isotope.
Has there been any progress on this idea? I know v2 is coming up and I was wondering if the situation had changed at all.
from isotope.
@seiyria yes! v2 docs have details about using functions for sorting and multiple sortBy.
from isotope.
@desandro Cool, thank you very much!
from isotope.
Isotope v2 is now released! See docs on filtering with function, and multiple sortBy
Merrily closing this old old issue. If you run into an issue with either of these features, please open a new issue.
from isotope.
Comes right in time thank you all very much :)
from isotope.
Related Issues (20)
- Error parsing data-masonry on row: SyntaxError: Expected property name or '}' in JSON at position 1
- 你们怎么解决的页面闪烁的问题?How do you solve the page flicker problem?
- How to scroll to a specific element during layout-animation? HOT 1
- Gutter works for columns not rows HOT 1
- error in docs example HOT 1
- filtering twice? HOT 2
- pile ties up when sorting? HOT 7
- Double loading of items when filtering or loading more HOT 1
- Using function and filter at the same time
- Strange spacing with filter active HOT 1
- Site is down HOT 1
- Images Stopped Displaying in Grid and Now in 1 Column. Should be 3 HOT 4
- Trying to filter buttons, search, and hash HOT 2
- Items get correctly displayed on 3 columns when using one filter, but get stacked on a single column if using a different filter HOT 3
- Issue with Icotope tab & Slick Slider HOT 2
- Istotope: CSS transitions/animations HOT 1
- This is a dead project, isn't it? HOT 2
- ignore
- unpkg links no longer working HOT 3
- Isotope Combination filters Dropdown HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from isotope.