D
Daniel Weinand
hello ng,
i have a problem and a imho an insufficient method of solution.
strings should be sorted by specific text pattern and dispayed
in groups. the strings are stored in a db and have the following layout:
1.0.0.0
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
1.2.0.0
1.2.1.0
1.2.3.0
1.2.29.0
1.7.0.0
1.7.4.0
1.7.5.0
2.13.12.0
2.14.1.0
17.255.1.0
17.255.2.0
12.255.24.0
....
'n'.'n'.'n'.'n'
the problem is now to sort the strings by groups.
sort key is either the first digit or the the first and
the second, or the first, the second and the third.
example:
if sort key is first digit, the following strings should be displayed.
1.0.0.0
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
1.2.0.0
1.2.1.0
1.2.3.0
1.2.29.0
1.7.0.0
1.7.4.0
1.7.5.0
according for digits 1...n. in worst case there can be all possible int
values.
should be searched an sorted for '1.1.x.x the values should be:
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
and so on....
at any time during runtime the required strings will be defined.
how can i solve this efficient and elegant?
my first method of solution is using array and loops.
using split() to separate the single values and verifying them.
it's half cooked for now, but its to forsee that it will end in a loop orgy.
that's neither volitional by myself nor by anyone else.
getting the values via 'sql like' is neither possible nor desired.
generally for sure, but not in
this special case.
a simple but ingenious solution is prefered.
unfortunately c# and
dotnet is pretty new for me,
so that i don't have the faintest idea how to solve this in a good manner.
thought about regular expressions or something like that.
perhaps anyone had a similiar problem and can help me with his ingenious
idea.
proposals? suggestions?
greetings
Daniel
i have a problem and a imho an insufficient method of solution.
strings should be sorted by specific text pattern and dispayed
in groups. the strings are stored in a db and have the following layout:
1.0.0.0
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
1.2.0.0
1.2.1.0
1.2.3.0
1.2.29.0
1.7.0.0
1.7.4.0
1.7.5.0
2.13.12.0
2.14.1.0
17.255.1.0
17.255.2.0
12.255.24.0
....
'n'.'n'.'n'.'n'
the problem is now to sort the strings by groups.
sort key is either the first digit or the the first and
the second, or the first, the second and the third.
example:
if sort key is first digit, the following strings should be displayed.
1.0.0.0
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
1.2.0.0
1.2.1.0
1.2.3.0
1.2.29.0
1.7.0.0
1.7.4.0
1.7.5.0
according for digits 1...n. in worst case there can be all possible int
values.
should be searched an sorted for '1.1.x.x the values should be:
1.1.0.0
1.1.1.0
1.1.2.0
1.1.17.0
and so on....
at any time during runtime the required strings will be defined.
how can i solve this efficient and elegant?
my first method of solution is using array and loops.
using split() to separate the single values and verifying them.
it's half cooked for now, but its to forsee that it will end in a loop orgy.
that's neither volitional by myself nor by anyone else.
getting the values via 'sql like' is neither possible nor desired.
generally for sure, but not in
this special case.
a simple but ingenious solution is prefered.

dotnet is pretty new for me,
so that i don't have the faintest idea how to solve this in a good manner.
thought about regular expressions or something like that.
perhaps anyone had a similiar problem and can help me with his ingenious
idea.
proposals? suggestions?
greetings
Daniel