-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
detecting and sorting version numbers #395
Comments
Hi @corbosman! Try using the $('table').tablesorter({
theme: 'blue',
headers: {
3: { sorter: "ipAddress" }
}
}); The biggest problem is when you write the version number that doesn't match the others. As seen in the screenshot you shared, |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue this discussion. |
The $.tablesorter.addParser({
id: 'versionNumber',
is: function() {
// Do not auto detect
return false;
},
format: function(text) {
var parts = text.split('.');
if(parts.length == 1) {
return parts[0] + '000' + '000';
} else if(parts.length == 2) {
return parts[0] + ('000' + parts[1]).slice(-3) + '000';
} else if(parts.length == 3) {
return parts[0] + ('000' + parts[1]).slice(-3) + ('000' + parts[2]).slice(-3);
}
return text;
},
type: 'numeric'
}); |
this is very very limited to be a version number parser, what about alpha, beta, etc I'll try and put something a little more robust together and post it here. |
id recommend basing the sorter off semver.. http://semver.org/ |
that is a very good example and this seems to be very complete, I agree with you zoggy Examples: 1.9.0 -> 1.10.0 -> 1.11.0. |
Thanks for the input guys! Honestly, instead of writing a widget that we have to maintain... we should just include that plugin and have the widget interact with it. |
sounds good to me, you on it or shall I look into it? |
@TheSin- Oh, I thought you were doing it... I've got a bunch of other stuff I'm trying to work on. And I haven't even gotten to the pull requests yet! |
no problem at all I just haven't linked to an external lib yet and I wasn't sure if you wanted to make the external lib a git module etc etc. I'll try and get a version of this to approval ;) |
Hmm, maybe the code from this StackOverflow question would work... I haven't tested it, but the demo includes some testing: http://jsfiddle.net/ripper234/Xv9WL/28/ Edit: Ugh, nevermind... I think it would be easier to just include the file. I know about git modules, but never got around to learning how to add and maintain them. What do you think? |
git modules are a bit funky. you basically include it and reference which commit you want to include at.. it doesnt really include anything.. just think of it like a shortcut. when people clone your repo they actually dont get the submodule.. unless they do a specific command to get them.. which most people dont know/takes extra effort. in the end we gave up on using them for one of the projects we worked on since it was causing more headaches than it was worth. |
I've also looked at git-subtree before; but in this case I think you need admin privileges in both repos. |
Any news on this @TheSin-? No rush, I was just looking at issues to see what I need to do next. |
sadly I haven't had any time at all been working on an other project and I have a major dealer seminar that I need to present at in 2 week in the UK, 10 presentations in 2 days, so been pretty busy, it's still on my list though. |
No, worries, I can do it. Good luck! |
Wow, this semver parser project is WAY more complicated than I anticipated. What I started doing is modifying the semver.js code which I know think should be used as the sorter instead a parser (using Then it gets complicated LOL As @TheSin- shared before, the next statement is how SemVer 2.0.0 does comparisons
But then I read comments like this (from isaacs, the guy who wrote semver.js)
So, should we only support SemVer 2.0.0, or allow the parser/sorter to also work with older formatting? Or write two parsers/sorters that allow the user to choose which one they want to support? bangs head into desk |
Here's a demo of what I have so far: http://jsfiddle.net/Mottie/abkNM/1626/ |
Only semver 2. -----Original Message----- Wow, this semver parser project is WAY more complicated than I anticipated. What I started doing is modifying the semver.js code which I know think should be used as the sorter instead a parser (using Then it gets complicated LOL As @TheSin- shared before, the next statement is how SemVer 2.0.0 does comparisons
But then I read comments like this (from isaacs, the guy who wrote semver.js)
So, should we only support SemVer 2.0.0, or allow the parser/sorter to also work with older formatting? Or write two parsers/sorters that allow the user to choose which one they want to support? bangs head into desk Reply to this email directly or view it on GitHub: |
this is correct, version-[0-9]+ = revision of a version and in it's self is higher then the base version. |
awesome. thanks. |
very nice Rob, and great work! |
Just a quick update... this is code for a generic version, or number block, parser (demo): $(function () {
/************************
Generic version parser
************************/
// set the number of blocks
// e.g. 2 = 000.000
// and 3 = 000.000.000
var blocks = 3,
// length of each block
// 3 = 000
// 4 = 0000
digits = 3;
$.tablesorter.addParser({
id: "versions",
is: function (s) {
return false;
},
format: function (s, table) {
var i,
a = s ? s.split(".") : [],
r = "",
d = new Array(digits + 1).join('0');
for (i = 0; i < blocks; i++) {
r += (d + (a[i] || 0)).slice(-digits);
}
return s ? $.tablesorter.formatFloat(r, table) : s;
},
type: "numeric"
});
$('table').tablesorter({
theme: 'blue',
headers: {
3: { sorter: "versions" }
}
});
}); |
I cant seem to figure out a way to sort a column with version numbers. They're not sorting properly. Screenshot: http://grab.by/rr04
Cor
The text was updated successfully, but these errors were encountered: