Bug 150328 - Sorting Peers by IP Address sorts incorrectly
Summary: Sorting Peers by IP Address sorts incorrectly
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-29 17:50 UTC by Ami Setton
Modified: 2007-10-21 18:31 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Sort ip correctly in infowidget peerview (1.65 KB, patch)
2007-10-21 02:09 UTC, dvj
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ami Setton 2007-09-29 17:50:42 UTC
Version:           2.1 (using KDE KDE 3.5.6)
Installed from:    Ubuntu Packages
OS:                Linux

If the column "IP Address" is chosen to sort, by, KTorrent sorts by treating the IP Address as a string, rather than as a numeric entity.  For example "222.x.x.x" would be seen earlier than "24.x.x.x".

I believe it should sort by IP Address numerically, not by the displayed string value.
Comment 1 dvj 2007-10-21 02:09:19 UTC
Created attachment 21881 [details]
Sort ip correctly in infowidget peerview
Comment 2 dvj 2007-10-21 02:11:05 UTC
That's the first C++ patch I've done, so be critical. How else would I learn? :)
Comment 3 Ami Setton 2007-10-21 06:11:39 UTC
Hey there, dvj.

Firstly, thanks a lot for addressing the issue! I'll guess you meant that the bug assignee should check the patch...but, hey, I'll in throw my $0.02, just for fun.  

1) What about just using inet_aton on both IPs and comparing the results?  There might be a lo of back-and-forth about what's more expensive, but if you lost some lines of code, it might be worth any expense (_if_ it's more expensive.)
2) Did you mean "digits" in your variable names instead of "digets" ?
Comment 4 Joris Guisson 2007-10-21 10:05:56 UTC
It would be much faster to convert the string ones and then compare with converted value, much faster.
Comment 5 Joris Guisson 2007-10-21 10:06:26 UTC
Oops, typo : ones -> once
Comment 6 Joris Guisson 2007-10-21 10:08:04 UTC
SVN commit 727609 by guisson:

Sort IP addresses by their actual value and not by their string representation

BUG: 150328


 M  +11 -6     peerview.cpp  
 M  +1 -0      peerview.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=727609
Comment 7 Ami Setton 2007-10-21 18:31:06 UTC
Thanks, Joris!